[wp-trac] [WordPress Trac] #54738: Unable to upload images with URL over API when the image doesn’t have a filetype in the filename
WordPress Trac
noreply at wordpress.org
Fri Feb 18 17:12:47 UTC 2022
#54738: Unable to upload images with URL over API when the image doesn’t have a
filetype in the filename
--------------------------+------------------------------
Reporter: masteradhoc | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Resolution:
Keywords: | Focuses: rest-api
--------------------------+------------------------------
Comment (by mitogh):
Adding the steps to replicate the problem using functions either directly
on a script or via WP shell.
{{{
$file = download_url( 'https://media.istockphoto.com/photos/coppersmith-
repair-copper-kettle-on-fire-in-kashgar-in-xinjiang-picture-
id1298102169?s=612x612' )
$result = media_handle_sideload( $file )
// This would be an error because file would use a .tmp extension which is
not valid to be uplodaed.
var_dump( $result );
}}}
Mainly the problem is because the header content is not considered as part
of the mime type instead the extension of the file is used to indicate
which mime type is.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54738#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list