strip path and extension when loading doodle from file

This commit is contained in:
Rick Companje 2021-06-06 20:55:49 +02:00
parent 71ea685880
commit 86ac70678b

View File

@ -120,8 +120,12 @@ export const openFileSelector = () => {
const imgBlob = await generateThumb(sketcherState, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 'blob'); const imgBlob = await generateThumb(sketcherState, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 'blob');
const sketchBlob = new Blob([sketchData], { type: 'application/json' }); const sketchBlob = new Blob([sketchData], { type: 'application/json' });
let name = /[^/]*$/.exec(fileName)[0]; //remove path
if (name) name = name.replace(".doodle3d",""); //remove extension
if (!name) name = fileName; //fallback to fileName if needed
const doc = { const doc = {
name: fileName.replace(".doodle3d",""), name: name,
appVersion: VERSION, appVersion: VERSION,
_attachments: { _attachments: {
img: { content_type: imgBlob.type, data: imgBlob }, img: { content_type: imgBlob.type, data: imgBlob },