nuxt migration -file upload - WIP (#271)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -79,6 +79,7 @@
|
||||
import { inputProps, useFormInput } from './useFormInput.js'
|
||||
import InputWrapper from './components/InputWrapper.vue'
|
||||
import UploadedFile from './components/UploadedFile.vue'
|
||||
import {storeFile} from "~/lib/file-uploads.js"
|
||||
|
||||
export default {
|
||||
name: 'FileInput',
|
||||
@@ -186,7 +187,7 @@ export default {
|
||||
uploadFileToServer (file) {
|
||||
if (this.disabled) return
|
||||
this.loading = true
|
||||
this.storeFile(file)
|
||||
storeFile(file)
|
||||
.then((response) => {
|
||||
if (!this.multiple) {
|
||||
this.files = []
|
||||
@@ -195,8 +196,10 @@ export default {
|
||||
// Move file to permanent storage for form assets
|
||||
opnFetch('/open/forms/assets/upload', {
|
||||
method: 'POST',
|
||||
type: 'files',
|
||||
url: file.name.split('.').slice(0, -1).join('.') + '_' + response.uuid + '.' + response.extension
|
||||
body: {
|
||||
type: 'files',
|
||||
url: file.name.split('.').slice(0, -1).join('.') + '_' + response.uuid + '.' + response.extension
|
||||
}
|
||||
}).then(moveFileResponseData => {
|
||||
this.files.push({
|
||||
file: file,
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
import { inputProps, useFormInput } from './useFormInput.js'
|
||||
import InputWrapper from './components/InputWrapper.vue'
|
||||
import Modal from '../global/Modal.vue'
|
||||
import {storeFile} from "~/lib/file-uploads.js"
|
||||
|
||||
export default {
|
||||
name: 'ImageInput',
|
||||
@@ -187,11 +188,13 @@ export default {
|
||||
uploadFileToServer () {
|
||||
this.loading = true
|
||||
// Store file in s3
|
||||
this.storeFile(this.file).then(response => {
|
||||
storeFile(this.file).then(response => {
|
||||
// Move file to permanent storage for form assets
|
||||
opnFetch('/open/forms/assets/upload', {
|
||||
method: 'POST',
|
||||
url: this.file.name.split('.').slice(0, -1).join('.') + '_' + response.uuid + '.' + response.extension
|
||||
body: {
|
||||
url: this.file.name.split('.').slice(0, -1).join('.') + '_' + response.uuid + '.' + response.extension
|
||||
}
|
||||
}).then(moveFileResponseData => {
|
||||
if (!this.multiple) {
|
||||
this.files = []
|
||||
|
||||
Reference in New Issue
Block a user