First use of exif tags!

This commit is contained in:
Timothy Warren 2018-04-16 16:37:00 -04:00
parent 365e69c589
commit 2bad69ace0
4 changed files with 22 additions and 14 deletions

View File

@ -38,6 +38,7 @@
}], }],
"prefer-const": "error", "prefer-const": "error",
"no-alert": "error", "no-alert": "error",
"no-case-declarations": "off",
"no-console": "off", "no-console": "off",
"no-duplicate-imports": "error", "no-duplicate-imports": "error",
"no-eval": "error", "no-eval": "error",

View File

@ -46,17 +46,8 @@ export class App extends Component {
}); });
window.clientWS.onmessage = message => { window.clientWS.onmessage = message => {
console.info(message);
console.info(message.data);
console.info(JSON.parse(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 () { onWebSocketClose () {

View File

@ -1,18 +1,35 @@
/** /**
* Websocket event handlers * Websocket event handlers
*/ */
const {ExifTool} = require('exiftool-vendored');
const {JSONMessage} = require('../helpers/web-socket'); const {JSONMessage} = require('../helpers/web-socket');
const exiftool = new ExifTool();
module.exports = (wss) => { module.exports = (wss) => {
wss.on('connection', ws => { wss.on('connection', ws => {
ws.send(JSONMessage('server-log', 'Connected to client!')); ws.send(JSONMessage('server-log', 'Connected to client!'));
ws.on('message', (...args) => { 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 => { default:
ws.send(JSONMessage('recieved-dropped-files', e)); return ws.send(JSONMessage('server-log', [type, message]));
}
}); });
}); });
}; };
function getExifTags (imgPath) {
return exiftool.read(imgPath);
}

View File

@ -11,7 +11,6 @@ function handleDrop (e) {
const draggedFiles = []; const draggedFiles = [];
for (const f of e.dataTransfer.files) { for (const f of e.dataTransfer.files) {
console.log('Dragged files', f.path);
draggedFiles.push(f.path); draggedFiles.push(f.path);
} }