Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Veyssier <eneiluj@posteo.net>2021-10-18 19:43:31 +0300
committerJulien Veyssier <eneiluj@posteo.net>2022-01-03 12:27:33 +0300
commitab992063c1225bad80f529eba8de89bbdd4c0b94 (patch)
tree6b0052bd16f7ab517b0ae3ec8f75f9f9cce2bd83 /src/components/MenuBar.vue
parentba3fc843426ab8762544c9af39ede77a870d41a0 (diff)
basic upload ok
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'src/components/MenuBar.vue')
-rw-r--r--src/components/MenuBar.vue35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue
index 59faec702..7334600a2 100644
--- a/src/components/MenuBar.vue
+++ b/src/components/MenuBar.vue
@@ -312,6 +312,7 @@ export default {
},
onUploadImage(command) {
console.debug('onUploadImage', command)
+ this.imageCommand = command
this.$refs.imageFileInput.click()
},
onImageFilePicked(event) {
@@ -323,9 +324,39 @@ export default {
this.imageUrl = fileReader.result
})
fileReader.readAsDataURL(files[0])
- this.image = files[0]
+ const image = files[0]
console.debug('filename', filename)
- console.debug('this.image', this.image)
+ console.debug('image', image)
+
+ console.debug('OC.Files.getClient()', OC.Files.getClient())
+ const client = OC.Files.getClient()
+ client.putFileContents('/Text/' + filename, image, {
+ contentType: image.type,
+ contentLength: image.size,
+ overwrite: false,
+ }).then((response) => {
+ console.debug('file uploaded!!!!!!!!')
+ client.getFileInfo('/Text/' + filename).then((_status, fileInfo) => {
+ this.lastImagePath = fileInfo.path
+
+ // dirty but works so we have the information stored in markdown
+ const appendMeta = {
+ mimetype: fileInfo.mimetype,
+ hasPreview: fileInfo.hasPreview,
+ }
+ const path = optimalPath(this.filePath, `${fileInfo.path}/${fileInfo.name}`)
+ const encodedPath = path.split('/').map(encodeURIComponent).join('/')
+ const meta = Object.entries(appendMeta).map(([key, val]) => `${key}=${encodeURIComponent(val)}`).join('&')
+ const src = `${encodedPath}?fileId=${fileInfo.id}#${meta}`
+
+ this.imageCommand({
+ src,
+ alt: fileInfo.name,
+ })
+ })
+ }).catch((error) => {
+ console.error(error)
+ })
},
showImagePrompt(command) {
const currentUser = getCurrentUser()