post https://studio.edgeimpulse.com/v1/api/organizations//data//add
Add a new file to an existing data item.
import requests, io
ORGANIZATION_ID = 1
DATA_ITEM_ID = 1000
API_KEY = 'ei_...'
r = requests.post(
'https://studio.edgeimpulse.com/v1/api/organizations/' + ORGANIZATION_ID + '/data/' + DATA_ITEM_ID + '/add',
headers={
'x-api-key': API_KEY
},
files=(
('files[]', ('hello.txt', open('/Users/janjongboom/Downloads/hello.txt', 'rb'), 'text/plain')),
)
)
print('returned', r, r.content)
curl -X POST -H \"x-api-key: ei_YOUR_API_KEY\" \\
https://studio.edgeimpulse.com/v1/api/organizations/ORGANIZATION_ID/data/DATA_ITEM_ID/add \\
-F files[]=@/Users/janjongboom/Downloads/hello.txt
const request = require('request');
const fs = require('fs');
const ORGANIZATION_ID = 1;
const DATA_ITEM_ID = 1000;
const API_KEY = 'ei_YOUR_API_KEY';
// Make the request with an empty 'formData' object, so we can manipulate this later
let req = request.post(`https://studio.edgeimpulse.com/v1/api/organizations/${ORGANIZATION_ID}/data/${DATA_ITEM_ID}/add`, {
headers: {
'Content-Type': 'multipart/form-data',
'x-api-key': API_KEY
},
formData: { }
}, (_err, resp, body) => {
if (_err) {
return console.error('Error when doing request', _err);
}
else if (resp.statusCode !== 200) {
return console.error('statusCode was not 200, but ' + resp.statusCode);
}
else {
console.log('Request succeeded', body);
}
});
// the request actually gets sent at the next tick so we can still manipulate this
let form = req.form();
form.append('files[]', fs.readFileSync('/Users/janjongboom/Downloads/hello.txt'), {
contentType: 'text/plain',
filename: 'hello.txt'
});