#20984 closed defect (bug) (invalid)
XMLRPC: wp.uploadFile missing base64_decode
Reported by: | fishc4ke | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.4 |
Component: | XML-RPC | Keywords: | |
Focuses: | Cc: |
Description
Uploading images via wp.uploadFile results in a broken image as the base64 bits are not decoded again.
Looking at the code, the file is written to disk by the function wp_upload_bits in functions.php.
A fix would be to alter line 1615 of functions.php:
@fwrite( $ifp, $bits );
to
@fwrite( $ifp, base64_decode($bits) );
However, I have not tested to see if this would break any other functionality.
Change History (7)
#2
@
12 years ago
The codex page states that bits' needs to be a base64-encoded, so I am simply opening the file and base64-encoding its contents (via Python 2.7.3) before uploading.
#3
@
12 years ago
Can you supply the exact XML-RPC request you are sending to WordPress? If you are using the base64 value type as defined in the spec, then it should be doing the Right Thing.
If you are using Python's xmlrpclib, you can take a look at my python wrapper library to see the correct way to handle binary data.
I am unable to reproduce this, can you please provide more details?
$bits
is actually binary data by that point, sinceIXR_Message
will callbase64_decode
beforemw_newMediaObject
(wp.uploadFile
) is ever called. See L303 of wp-includes/class-IXR.php.