Corrupted image when uploading using REST API (uploading as multipart file)

Hey guys, I know there’s another old topic like this one, but I got this problem on android.

I tested Ion library and loopj AsyncHttpClient. The upload image will be corrupted. What’s the solution?

It only get corrupted if I post it as a multipart file.

Can you provide more information as to how you’re posting the file?
I don’t need the code (since I’m Java illiterate), but if you can provide all the details of the api call, that will help.
What headers are you passing, what api call are you making, what content type are you posting (application/json?), etc?

What do you mean that it’s corrupted? Do you get any error messages from DF?

I’m posting an image/jpeg to http://localhost/api/v2/files with “Content-Type: multipart/form-data” as header. Also I encoded the image with Base64, didn’t work too. The image will be uploaded but when I try to open it, just a blank border shows up. Also I download the uploaded image to open it with a photo viewer application on my windows but it say’s “This is not a valid bitmap file”.

Notice that only when I’m posting the image as multipart file the problem appears.

Here’s how DF shows the image.

When I attempt to open the uploaded image from DreamFactory Files console, it shows:

The image “http://localhost/api/v2/files/test.jpg?api_key=MY_API_KEY&session_token=MY_SESSION_TOKEN” cannot be displayed because it contains errors.

1 Like

Hey @hedisam is this still an issue for you? Or have you solved it?


Hi, I have the same problem.
Uploaded file size is ok. but it is not shown as a picture.

When I try to open it in browser i get this error:
The image … cannot be displayed because it contains errors.

1 Like

anyone found solution ? please help . in am stuck with same issue .