- private function outputFileFromStash( $key ) {
- $file = $this->stash->getFile( $key );
- return $this->outputLocalFile( $file );
+ private function parseKey( $key ) {
+ $type = strtok( $key, '/' );
+
+ if ( $type !== 'file' && $type !== 'thumb' ) {
+ throw new UploadStashBadPathException( "Unknown type '$type'" );
+ }
+ $fileName = strtok( '/' );
+ $thumbPart = strtok( '/' );
+ $file = $this->stash->getFile( $fileName );
+ if ( $type === 'thumb' ) {
+
+ $parts = explode( "-{$fileName}", $thumbPart );
+
+ if ( count( $parts ) != 2 || $parts[1] !== '' ) {
+ throw new UploadStashBadPathException( 'Invalid suffix' );
+ }
+
+
+ $handler = $file->getHandler();
+ $params = $handler->parseParamString( $parts[0] );
+ return array( 'file' => $file, 'type' => $type, 'params' => $params );
+ }
+
+ return array( 'file' => $file, 'type' => $type );