File Upload via Byte Array API

I am attempting to use the save Files from Byte Arrays API and it isn’t working. I receive a 404 error code. I’ve double checked the permissions for the folder and made sure that the folder does exist in the File Storage. I’ve tried it using cURL from the command line which I get a different error of: {“code”:4000,“message”:“User has no permissions to specified resource”}.

Also, If I change the HTTP call from PUT to POST, I receive a 200 but nothing is saved.

Hi!

Please provide curl request which you use.
Regards,
Kate.

curl -k -H “application-id: 9…0” -H “secret-key: 2…0” -H “Content-Type: text/plain” -H “application-type: REST” -v -d bXkgY29vbCBub3Rl -X PUT “http://api.backendless.com/v1/files/binary/testFolder/savedNote.txt?overwrite=true

I can not reproduce this issue with my application.

Please send me your app id. We will check it with your app.
My email: kate@backendless.com

“application-id: 9B5E9EE0-B04B-350F-FFEC-D09044FBEA00”

Go to Users page -> Security and restrictions. And please check permissions for not authenticated user (for files). All permissions are DENY. So you can not create new folder in file service.

I have changed the permissions to allow all levels of File access and i’m still getting errors.

In the case that the file doesn’t exist before the file upload, I am receiving a 404 response. This same error happens when the file exists before I upload via my application.

The permissions for the folders had all allow overrides to allow authenticated and non-authenticated users to the folderr

The REST documentation states the Content-Type should be application/json but example shows text/plain.

What are the acceptable types? Can it handle application/octet-stream like the other file upload API can?

  1. I have changed the permissions to allow all levels of File access and i’m still getting errors.

Please re-check permissions for files in file service (for files and for folders)
2. What are the acceptable types?
You can use only text/plain request.

I created a new application and all permissions are set to allow but I’m not able to create a file either (404)

You are correct I did need the “binary” in the URL and I missed that entirely from reading the docs. So the root path of the File Storage is https://api.backendless.com/<version>/files/binary/

If the data sent is not in the form of Base64, the file is saved but the non Base64 is garbage. The response code is still 200. (i.e - “bXkgY29vbCBub3Rl - extra data here!”)

The documentation needs to be update for Save Files From Byte Arrays

Content-Type- the static value, should be set to application/json. This header is mandatory.

The type must be text/plain

Also the documentation for the Save Files from Byte Arrays needs up for the response returned which is https instead of http.

i.e. - The server will return the URL of the newly saved file:“http://api.backendless.com/D2F2F64A-67D0-2183-FF96-3F6167797700/v1/files/testFolder%2FsavedNote.txt
Change to:
https://api.backendless.com/D2F2F64A-67D0-2183-FF96-3F6167797700/v1/files/testFolder%2FsavedNote.txt

Also the documentation for the Save Files from Byte Arrays states the URL to be:

https://api.backendless.com/<version>/files/binary/<filePath>?overwrite=true

It should be changed to indicate the root path isn’t restricted to “/binary” directory:

https://api.backendless.com/<version>/files/<filePath>?overwrite=true

/binary was removed from the doc. Thank you for pointing this out.

Regards,
Mark

I could not find this in the doc. Could you please attach a screenshot of where you see it?