Skip to content

Commit 6768496

Browse files
committed
Release 19 May 2022
1 parent e6a27d3 commit 6768496

File tree

6 files changed

+364
-827
lines changed

6 files changed

+364
-827
lines changed

cli/daemon.ts

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import { Config, EdgeImpulseConfig } from './config';
1616
import { findSerial } from './find-serial';
1717
import { canFlashSerial } from './can-flash-serial';
1818
import jpegjs from 'jpeg-js';
19-
import { makeImage } from './make-image';
2019
import { RemoteMgmt, RemoteMgmtDevice, RemoteMgmtDeviceSampleEmitter } from '../shared/daemon/remote-mgmt-service';
2120
import { EventEmitter } from "tsee";
2221
import { getCliVersion, initCliApp, setupCliApp } from './init-cli-app';
2322
import { Mutex } from 'async-mutex';
2423
import WebSocket from 'ws';
2524
import encodeLabel from '../shared/encoding';
25+
import { upload } from './make-image';
2626

2727
const TCP_PREFIX = '\x1b[32m[WS ]\x1b[0m';
2828
const SERIAL_PREFIX = '\x1b[33m[SER]\x1b[0m';
@@ -354,39 +354,21 @@ class SerialDevice extends (EventEmitter as new () => TypedEmitter<{
354354
height: height,
355355
}, 100);
356356

357-
let filename = s.label + '.jpg';
358-
let processed = makeImage(jpegImageData.data, this._deviceConfig.sampling.hmacKey, filename);
359-
360-
let headers: { [k: string]: string} = {
361-
'x-api-key': this._deviceConfig.upload.apiKey,
362-
'x-file-name': encodeLabel(filename),
363-
'Content-Type': (!processed.attachments ? processed.contentType : 'multipart/form-data'),
364-
'Connection': 'keep-alive'
365-
};
366-
367-
headers['x-label'] = encodeLabel(s.label);
368-
369357
let url = this._config.endpoints.internal.ingestion + s.path;
370358
console.log(SERIAL_PREFIX, 'Uploading to', url);
371359

372360
ee.emit('uploading');
373361

374-
await request.post(
375-
this._config.endpoints.internal.ingestion + s.path, {
376-
headers: headers,
377-
body: (!processed.attachments ? processed.encoded : undefined),
378-
formData: (processed.attachments ? {
379-
body: {
380-
value: processed.encoded,
381-
options: {
382-
filename: filename,
383-
contentType: processed.contentType
384-
}
385-
},
386-
attachments: processed.attachments
387-
} : undefined),
388-
encoding: null,
389-
});
362+
await upload({
363+
filename: s.label + '.jpg',
364+
allowDuplicates: false,
365+
apiKey: this._deviceConfig.upload.apiKey,
366+
buffer: jpegImageData.data,
367+
category: s.path.indexOf('training') ? 'training' : 'testing',
368+
config: this._config,
369+
label: { label: s.label, type: 'label' },
370+
boundingBoxes: [],
371+
});
390372

391373
console.log(SERIAL_PREFIX, 'Uploading to', url, 'OK');
392374
}

0 commit comments

Comments
 (0)