Hi,
i cant add uploaded file from UploadButton to product media
i got this error:
{“message”:“Bad Request”,“details”:{}}
upload the file code:
var fabricImage
export function uploadButton2_change() {
$w("#uploadButton2").startUpload()
.then((uploadedFile) => {
fabricImage = uploadedFile.url;
})
}
add image to product:
import { mediaNewProductBackendFunction } from 'backend/fabricInventory';
.....
createNewProductBackendFunction(newProduct) // create new product(working)
.then(async(productResult) => {
const mediaData=[{fabricImage}]
let productId=productResult._id
await mediaNewProductBackendFunction(productId,mediaData)
})
backend code:
export function mediaNewProductBackendFunction(productId, mediaData) {
return wixStoresBackend.addProductMedia(productId, mediaData);
}