The error is as follows:
error_code:-2100,
error_description:"site uploads require original_file_name",
error_info:{
key:"wpm_error.missing_mandatory_parameter"
}
What i am trying to do:
I am trying to upload an image to my wix site’s mediaManager in a user specific folder from an app i am developing.
I recieve the uploadUrl by calling mediaManager.getUploadUrl(), which i use to upload the picture as a blob using the following code:
const PostWithNewPic = async (fromWixMedia:wixMedia, initialTime:any) => {
const fetchImage = await fetch(uploadPic.uri);
const blob = await fetchImage.blob();
let formData = new FormData();
const body = {
upload_token:fromWixMedia.uploadToken,
file:{
value:blob,
options:{
filename:uploadPic.fileName,
contentType:'picture'
}
}
}
formData.append('file', JSON.stringify(body))
return fetch(fromWixMedia.uploadUrl, {
method: 'POST',
headers: { 'Content-Type':'multipart/form-data' },
body:formData,
}).then(data => {
console.log(new Date().getTime()-initialTime);
console.log(data);
data.json().then(r=>{
console.log(r);
})
}).catch(e => { console.log('Error: ' + e.toString()) });
}
I expect to receive a returned object detailing the image’s information from the media manager. Instead, I receive:
As the error states, original_file_name is required. I supply the image’s name as required in the getUploadUrl documentation. The documentation states that original_file_name is one of the parameters of the returned object after uploading.
I have tried adding original_file_name to each level of the body object with no success.