Having trouble figuring out what is need to successfully upload a file that contains spaces in the filename and also a directory that contains spaces. I’ve tried replaces the spaces with %20 but still am getting a 400 bad request response. What is the correct cURL syntax for this?
curl -H application-id:A7B…00 -H secret-key:655…00 -H Content-Type:“multipart/form-data” -H application-type:REST --form upload=@“my file is this.txt” -X POST -v “https://api.backendless.com/v1/files/Testfiles/myfile is this.txt”
curl -H application-id:A7B…00 -H secret-key:655…00 -H Content-Type:“multipart/form-data” -H application-type:REST --form upload=@“my file is this.txt” -X POST -v “https://api.backendless.com/v1/files/Test files/myfile is this.txt”
Try the suggestion in this thread:
The documented you pointed to help with spaces in the input filename but what I don’t know is how to format the URL that contains spaces in either the directory name or the file that will be created as a result of the REST API call.
Can you point me to a solution?
Here’s a curl request I just tried:
curl -H application-id:MYAPPID -H secret-key:RESTSECRETKEY -H Content-type:“multipart/form-data” --form firstname.lastname@example.org -X POST -v “http://api.backendless.com/v1/files/txtfiles/dir%20with%20spaces/test.txt”
Here’s the response from the server:
Here’s the created directory (as seen in console):
I tried your exact curl command and I didn’t get the same results. Below is the request and response. I would like to be able to support REST API calls to upload a file with a filename and/or with spaces.
Sorry, I posted the snapshot of a request with the file already uploaded. Here is the clean request response. I tried the URL enclosed with quotes like you had and also got the same response.
Trying to figure out the necessary encoding in order to upload a file to a directory that contains spaces in its name.
The following curl command doesn’t work for me. The response contains the directory name - …/txtfiles/dir0with0spaces/test.txt. NOTE: The directory in Backendless didn’t exist prior to the curl call.
curl -H application-id:APPID -H secret-key:SECRET_KEY -H Content-type:“multipart/form-data” --form email@example.com -X POST -v “http://api.backendless.com/v1/files/txtfiles/dir%20with%20spaces/test.txt”
In this I created the directory first in Backendless. The response in this case is:
curl -H application-id:A7B8F6E8-1688-922F-FFB7-6DAC5CAE6C00 -H secret-key:655E37FB-70D0-53E8-FF5D-ABBBE7720800 -H Content-type:“multipart/form-data” --form firstname.lastname@example.org -X POST -v “http://api.backendless.com/v1/files/txtfiles/dir1 with spaces/test.txt”
Request using ‘+’ in URL for spaces in directory
curl -H application-id:A7B8F6E8-1688-922F-FFB7-6DAC5CAE6C00 -H secret-key:SKEY -H Content-type:“multipart/form-data” --form email@example.com -X POST -v "http://api.backendless.com/v1/files/txtfiles/dir2+with+spaces/test.txt";
So you can use both %20 and + for whitespaces, right?
I can use the %20 and + but the response should contain the spaces also. In addition, the directory that is actually created by the request should reflect the spaces in the directory name.