Closed emonkak closed 6 years ago
I really dislike problems that are multi-library problems. There are two things in play here:
ServerRequestCreator::createUploadedFileFromSpec
returns an instance (or (nested) array) of PSR-7 UploadedFileInterface
from whichever factory you have provided. These instances include the error code (which is being passed along), so theoretically we shouldn’t have to do any other upload error processing.
PSR-17 UploadedFileFactoryInterface::createUploadedFile
requires a valid PSR-7 StreamInterface
. The code as it is currently assumes that StreamFactoryInterface::createStreamFromFile
is just always going to work. Which is not a good idea. In case it goes wrong I think we should be creating an empty instance instead.
The factory you are using (is it nyholm/psr7?) doesn’t seem to throw a \RuntimeException
when it fails to create the stream instance. (Or it did, but you didn’t see it?) This goes against PSR-17, so the fix I described above wouldn’t solve your issue!
The factory library you are using will need to change to correctly handle \fopen
failures. Which is outside of this package’s control.
@emonkak I would appreciate it if you could have a look at my PR and let me know if this solves the issue for you: Nyholm/psr7-server#21.
The following warning is occurred because trying to create a stream from an empty filename.
The problem is in
createUploadedFileFromSpec()
function. I think that the function should check for upload errors.