I am currently attempting to upload the file to Backendless storage using the REST API but I get an error 400 while trying to do so.
I use React Native and Fetch API to do the job. OS is Android 10.
Here is the code that handles the upload:
const handleUpload = async () => {
const url = `https://api.backendless.com/${keys.APPLICATION_ID}/${
keys.REST_API_KEY
}/files/${remotePath}/${file.name}?overwrite=true`;
const body = new FormData();
body.append(file);
body.append('user-token', user.userToken);
console.log(await fetch(url, {method: 'POST', body}));
};
file
contains the URI, type, and name as supplied by react-native-document-picker library.
Return log:
{"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "xxxxxx", "offset": 0, "size": 108}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "xxxxxx", "offset": 0, "size": 108}}, "headers": {"map": {"access-control-allow-methods": "POST, GET, OPTIONS, PUT, DELETE, PATCH", "access-control-allow-origin": "*", "connection": "keep-alive", "content-length": "108", "content-type": "application/json", "date": "Mon, 29 Jun 2020 15:20:02 GMT", "server": "nginx", "strict-transport-security": "max-age=31536000; preload"}}, "ok": false, "status": 400, "statusText": undefined, "type": "default", "url": "https://api.backendless.com/CD8B0A40-0E0D-070F-FF5D-2E6AC915F900/xxxxxx/files/user/20200629_161148.jpg?overwrite=true"}