I’m working on a React Native project that has an interface to upload media (with path “file://”) from a mobile device to our Omeka database, but I’ve been having trouble sending a post request using axios. Has anyone been able to successfully upload a file to Omeka using RN or React, or anything similar? I’ve tried converting other requests in languages like Python or using curl but they’ve been unsuccessful. Here’s a snippet of my POST request:
let item = {
“o:media”: [
{
“o:ingester”: “upload”,
file_index: “0”,
“o:item”: {},
“dcterms:title”: [
{
property_id: 1,
property_label: “Title”,
“@value”: “My Image”,
type: “literal”,
},
],
},
],
“dcterms:title”: [
{
type: “literal”,
property_id: 1,
property_label: “Title”,
is_public: true,
“@value”: “My Item”,
},
],
};
let payload = {
data: item,
“file[0]”: IMAGE_URI,
};
axios
.post(“http://address/api/media”, payload, {
params: {
key_identity: KEY_IDENTITY",
key_credential: KEY_CREDENTIAL,
},
})
.then((res) => {console.log(res, ‘res’})
.catch((error) => console.log(“error”, error.message));
})
And sending this gives me an error 422. Thanks in advance!