Page MenuHomePhabricator

Extension code can't get stashed file's path from UploadFromStash
Closed, DeclinedPublic

Description

I have not completely deciphered the Upload classes, so I apologize if I misunderstand.

For the extension development I'm doing, I'm working with a specialized subclass of SpecialUpload that sometimes interrupts the final stage of uploading, and does other work with the file contents rather than publishing it to a File: page.

When the file is uploaded directly, it seems I can find it using $this->mUpload->getTempPath() and operate on the file contents, but if the file has been stashed and mUpload is now an UploadFromStash object, that doesn't work.

The only way I can see to get the stashed file's path is to ignore mUpload, go back to the session key from the request data, and use UploadStash::getMetadata() to find out where the file is. This requires me to violate UploadBase's polymorphism and handle the separate cases in my calling code.

Another option would be to call $this->mUpload->stashSession(), but if I'm not mistaken that would actually copy the file to a second stashed location, which is wasteful.

It would be helpful to have getTempPath() or a similar method give me the path of the stashed file, so that my code would not have to know whether $this->mUpload is stashed or not.


Version: 1.23.0
Severity: normal

Details

Reference
bz61705

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:57 AM
bzimport set Reference to bz61705.
bzimport added a subscriber: Unknown Object (MLST).

looks like getTempPath() works better than I thought when I use clearstatcache() at the right moments, so I'm going to withdraw this ticket.