Skip to content

Commit

Permalink
Fix editor image saving
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Aug 16, 2022
1 parent 8623af4 commit 34f2a29
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions js/viewer-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer-main.js.map

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions src/components/ImageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import client from '../services/DavClient.js'
import logger from '../services/logger.js'
import translations from '../models/editorTranslations.js'
import editorTranslations from '../models/editorTranslations.js'
const { TABS, TOOLS } = FilerobotImageEditor
Expand Down Expand Up @@ -121,10 +120,15 @@ export default {
async onSave(imageData) {
const filename = join(dirname(this.filename), imageData.fullName)
logger.debug('Saving image...', { src: this.src, filename, imageData })
logger.debug('Saving image...', { src: this.src, filename })
try {
const u8arr = Uint8Array.from(atob(imageData.imageBase64.split(';base64,').pop()))
await client.putFileContents(filename, u8arr.buffer)
const b64string = imageData.imageBase64.split(';base64,').pop()
const buff = Buffer.from(b64string, 'base64')
await client.putFileContents(filename, buff, {
// @see https://github.com/perry-mitchell/webdav-client#putfilecontents
// https://github.com/perry-mitchell/webdav-client/issues/150
contentLength: false,
})
logger.info('Edited image saved!')
} catch (error) {
logger.error('Error saving image', { error })
Expand All @@ -136,13 +140,13 @@ export default {
*/
onExitWithoutSaving() {
OC.dialogs.confirmDestructive(
editorTranslations.changesLoseConfirmation + '\n\n' + editorTranslations.changesLoseConfirmationHint,
translations.changesLoseConfirmation + '\n\n' + translations.changesLoseConfirmationHint,
t('viewer', 'Unsaved changes'),
{
type: OC.dialogs.YES_NO_BUTTONS,
confirm: t('viewer', 'Drop changes'),
confirmClasses: 'error',
cancel: editorTranslations.cancel,
cancel: translations.cancel,
},
(decision) => {
if (!decision) {
Expand Down

0 comments on commit 34f2a29

Please sign in to comment.