First use of exif tags!
This commit is contained in:
parent
365e69c589
commit
2bad69ace0
@ -38,6 +38,7 @@
|
||||
}],
|
||||
"prefer-const": "error",
|
||||
"no-alert": "error",
|
||||
"no-case-declarations": "off",
|
||||
"no-console": "off",
|
||||
"no-duplicate-imports": "error",
|
||||
"no-eval": "error",
|
||||
|
@ -46,17 +46,8 @@ export class App extends Component {
|
||||
});
|
||||
|
||||
window.clientWS.onmessage = message => {
|
||||
console.info(message);
|
||||
console.info(message.data);
|
||||
|
||||
console.info(JSON.parse(message.data));
|
||||
// const fr = new FileReader();
|
||||
// fr.readAsArrayBuffer(message.data);
|
||||
|
||||
// console.info(fr.result);
|
||||
};
|
||||
|
||||
console.info(window.clientWS);
|
||||
}
|
||||
|
||||
onWebSocketClose () {
|
||||
|
@ -1,18 +1,35 @@
|
||||
/**
|
||||
* Websocket event handlers
|
||||
*/
|
||||
const {ExifTool} = require('exiftool-vendored');
|
||||
const {JSONMessage} = require('../helpers/web-socket');
|
||||
|
||||
const exiftool = new ExifTool();
|
||||
|
||||
module.exports = (wss) => {
|
||||
wss.on('connection', ws => {
|
||||
ws.send(JSONMessage('server-log', 'Connected to client!'));
|
||||
|
||||
ws.on('message', (...args) => {
|
||||
console.info(args);
|
||||
const [type, message] = JSON.parse(args);
|
||||
switch (type) {
|
||||
case 'dropped-files':
|
||||
const filemap = [];
|
||||
message.forEach(async file => {
|
||||
const tags = await getExifTags(file);
|
||||
console.info(tags);
|
||||
filemap[file] = tags;
|
||||
});
|
||||
ws.send(JSONMessage('parsed-exif-tags', filemap));
|
||||
break;
|
||||
|
||||
ws.on('dropped-files', e => {
|
||||
ws.send(JSONMessage('recieved-dropped-files', e));
|
||||
default:
|
||||
return ws.send(JSONMessage('server-log', [type, message]));
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function getExifTags (imgPath) {
|
||||
return exiftool.read(imgPath);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ function handleDrop (e) {
|
||||
|
||||
const draggedFiles = [];
|
||||
for (const f of e.dataTransfer.files) {
|
||||
console.log('Dragged files', f.path);
|
||||
draggedFiles.push(f.path);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user