Image uploaded via REST API is always corrupt

I have been trying for a few hours to get the image upload API to work correctly. Running DF2.10 on Amazon ECS. I can use the files area of the admin portal and upload fine. When I try to upload using the REST API, the file is always corrupted.

I have read all of the posts on this already, and none seem to address this fully.

I am using the POST/{file path} method for this.

My method parameters are:
file_path: folder_name/user.png

with this in the body:

{
    "resource": [{
	    "name": "user.png",
	    "type": "file",
	    "is_base64": true,
	    "content": "base64 string of converted png"
    }]
}

The post is successful, and I get this response body:

{
    "name": "user.png",
    "path": "folder_name/user.png",
    "type": "file"
}

I can see the file in the files area. But if I click the file, it does not render. Downloading the file and opening it in Preview.app yields an error stating “It may be damaged or use a file format that Preview doesn’t recognize.”

I have tested the base64 string on multiple converters and not had any issues.

I get the same results using Postman to test the API.

Using this page as a guide and no luck.

Would appreciate any guidance.

I found a resolution, I had been posting to the URL with the full path and file name. Removing the file name from the url did the trick.

2 Likes