Unable to upload file

I’ve been uploading files successfully using the REST API and for a test I manually deleted the directory using the Backendless console. I try to upload a file from my application (no code changes) and the response is 200. I look in Backendless console for the directory and file that I uploaded and it didn’t create it.

I tried to manually create the directory from the console and I got the error: Unable to initialize directory: U2

I tried to upload another file via the REST API into a non existant directory in the Backendless console. The response was a 200 with a file URL. When I check in the Backenless console, the new directory is created but the upload file doesn’t exist.

How can you upload a file into a non-existing directory in Console? Our console shows only existing directories…

I fully agree with you. I found it very odd at the time it was happening and that is why I thought I would report the finding.

I am still seeing this problem where the API returns success but the console doesn’t show any files.

I am now see this error: Internal server error with id FCA7411C-8188-54B3-FF4B-90EF273C2600

I click the the directory in the console and I now get this error: {“code”:6007,“message”:“The specified resource was not found”}

I added a call to use the Directory Listing API and it does return correctly with this error: {“code”:6007,“message”:“The specified resource was not found”}

I tried upload a file using the API to a new directory and I get a success return value and the checking if the file exists returns a failure of {“code”:6007,“message”:“The specified resource was not found”}.

Hi Roy,

Could you please show your REST request (URL, headers, body)? Also, please attach a screenshot of the directory after you run the request.

Regards,
Mark

Still having trouble uploading files. The code hasn’t changed in months that I’m using. I will soon send the URL, headers, body data.

I am using the File Upload API for REST.

The URL is {“fileURL”:“https://api.backendless.com/85640f83-1394-1e16-fff8-1dce458cae00/v1/files/U2/Hints/testFile_.sg1”}

The HTTP headers are:

Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache
Accept-Language: en-us
application-id: 85640F83-1394-1E16-FFF8-1DCE458CAE00
secret-key: D7…
user-token: 615093B3-EB76-EEB1-FF73-CEDD000ED600
application-type: REST
Content-Type: multipart/form-data; boundary=sntL0zAndJPlkD4dhrYxORjDYGmXw

The request Body is:

–ADUBpVfVPA39ntIXp3gxuP2ZkBuzYl\r\nContent-Disposition: form-data; name=“files[]”; filename=“testFile_.sg1”\r\nContent-Type: application/octet-stream\r\n\r\n<BINARY_DATA HERE>\r\n–ADUBpVfVPA39ntIXp3gxuP2ZkBuzYl–\r\n

The above header Content-Type: multipart/form-data; boundary=sntL0zAndJPlkD4dhrYxORjDYGmXw

should be Content-Type: multipart/form-data; boundary=ADUBpVfVPA39ntIXp3gxuP2ZkBuzYl

Copy/paste problem…

Roy,

Could you please run the following curl request (with the secret key fixed up) and let us know what you get? The command must be run from the directory that contains the testFile_.sg1 file:

curl -H application-id:85640F83-1394-1E16-FFF8-1DCE458CAE00 -H secret-key:D7XXXXX -H Content-Type:“multipart/form-data” --form upload=@testFile_.sg1 -X POST http://api.backendless.com/v1/files/U2/Hints/testFile_.sg1

The curl command results below:

POST /v1/files/U2/Hints/testFile_.sg1 HTTP/1.1

Host: api.backendless.com

User-Agent: curl/7.43.0

Accept: /

application-id:85640F83-1394-1E16-FFF8-1DCE458CAE00

secret-key:D787BDBF-DD8F-17FC-FFFB-E916920ACC00

Content-Length: 227

Expect: 100-continue

Content-Type:multipart/form-data; boundary=------------------------b44c0c43d45418b9

HTTP/1.1 100 Continue

--------------------------b44c0c43d45418b9

Content-Disposition: form-data; name=“upload”; filename=“testFile_.sg1”

Content-Type: application/octet-stream

This is a test file.

--------------------------b44c0c43d45418b9–

HTTP/1.1 200 OK

Access-Control-Allow-Headers: Origin, application-id, application-type, Content-Type, secret-key, request, user-token

Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, PATCH

Access-Control-Allow-Origin: *

Cache-Control: no-cache

Cache-Control: : no-store, no-cache, must-revalidate, private

Content-Type: text/plain; charset=UTF-8

Date: Sat, 05 Mar 2016 10:39:37 GMT

Expires: Thu, 01 Jan 1970 00:00:01 GMT

Pragma: : no-cache

Server: nginx/1.4.2

Content-Length: 110

Connection: keep-alive

{“fileURL”:“https://api.backendless.com/85640f83-1394-1e16-fff8-1dce458cae00/v1/files/U2/Hints/testFile_.sg1”}

I get some wierd behavior from the console. The directory is created along with the file. When I click on the testFile… I get this error: {“code”:6007,“message”:“The specified resource was not found”}

After click on the file about 10+ times and getting the error 6007 each time, the file did open up.

After more attempts and errors of click on the file, I also get this error - Internal server error with id DCC58EA9-1E77-04E5-FFF4-4199E4A02600

Attached is show after uploading a file that the API return a success and fileURL but the file is not accessible. In addition the navigation in the console indicates the directory is actually a file.

I have deleted ALL my previous directories and left the media and web directories to try to start all over.

I am still getting the same errors.

Please upload a file so the problem shows up. Let us know your app ID and file URL.

Thanks,
Mark