Using Services "file create" resource in order to upload a base64 encoded string as a new file.

Everything seems to work as expected, the response returns the file fid but when trying to view the file on the browser, the file doesn't appear.
Looking at the database, the file seems to exists, showing the correct file size.

It turns out that removing the base64 header from the file data sent from the Javascript app fixes the problem.

Looking at the code in _file_resource_create(), I then replaced
base64_decode($file['file'])
with
file_get_contents($file['file'])

I'm a beginner when it comes to Drupal patches, but I've attached my solution below, just in case...

CommentFileSizeAuthor
filegetcontents.patch651 bytespsegarel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

psegarel created an issue. See original summary.

psegarel’s picture

Assigned: Unassigned » psegarel
Status: Active » Closed (cannot reproduce)