I started using strapi recently. I would like to upload a photo from my app (react native / expo), but I have errors that I don't understand.
First, I tested the photo upload on a server without strapi and I didn't experience any problem, the photo is sent.
const form = new FormData();
form.append('files', {uri: photoSource.uri, name: filename, type: 'image/jpeg'});
const requestConfig = {
method: 'POST',
headers: {
"Authorization": "Bearer ey...",
"Content-Type": "multipart/form-data;",
},
"body": form
};
const response = await fetch("http://myserveradresse/upload", requestConfig);
let responseJson = await response.json();
console.log(responseJson);
When I switched to Strapi, it didn't work anymore. As I saw that it was necessary to send a Buffer, I tried :
form.append('files', new Buffer(photoSource, 'base64'));
But it didn't work.
Before that, I also tried to use other methods to send the picture: FileSystem.uploadAsync, xmlhttprequest...
But nothing works. Strapi always sends me the same error:
Object {
"data": Object {
"errors": Array [
Object {
"id": "Upload.status.empty",
"message": "Files are empty",
},
],
},
"error": "Bad Request",
"message": "Bad Request",
"statusCode": 400,
}
I think I must have misunderstood something, but I can't figure out what.