@@ -77,12 +77,10 @@ import LinkIcon from 'vue-material-design-icons/Link.vue'
7777import PlusIcon from ' vue-material-design-icons/Plus.vue'
7878import UploadIcon from ' vue-material-design-icons/Upload.vue'
7979
80- import axios from ' @nextcloud/axios'
8180import { getCapabilities } from ' @nextcloud/capabilities'
8281import { showError } from ' @nextcloud/dialogs'
8382import { FilePickerVue as FilePicker } from ' @nextcloud/dialogs/filepicker.js'
8483import { loadState } from ' @nextcloud/initial-state'
85- import { generateOcsUrl } from ' @nextcloud/router'
8684
8785import NcActionButton from ' @nextcloud/vue/components/NcActionButton'
8886import NcActions from ' @nextcloud/vue/components/NcActions'
@@ -203,17 +201,8 @@ export default {
203201 }
204202
205203 await this .filesStore .upload (formData)
206- .then ((response ) => {
207- this .filesStore .addFile ({
208- nodeId: response .id ,
209- name: response .name ,
210- status: response .status ,
211- statusText: response .statusText ,
212- created_at: response .created_at ,
213- ... (response .nodeType && { nodeType: response .nodeType }),
214- ... (response .files && { files: response .files }),
215- })
216- this .filesStore .selectFile (response .id )
204+ .then ((nodeId ) => {
205+ this .filesStore .selectFile (nodeId)
217206 })
218207 .catch (({ response }) => {
219208 showError (response .data .ocs .data .message )
@@ -241,23 +230,13 @@ export default {
241230 },
242231 async uploadUrl () {
243232 this .loading = true
244- await axios . post ( generateOcsUrl ( ' /apps/libresign/api/v1/file ' ), {
233+ await this . filesStore . upload ( {
245234 file: {
246235 url: this .pdfUrl ,
247236 },
248237 })
249- .then (({ data }) => {
250- this .filesStore .addFile ({
251- nodeId: data .ocs .data .id ,
252- uuid: data .ocs .data .uuid ,
253- name: data .ocs .data .name ,
254- status: data .ocs .data .status ,
255- statusText: data .ocs .data .statusText ,
256- created_at: data .ocs .data .created_at ,
257- ... (data .ocs .data .nodeType && { nodeType: data .ocs .data .nodeType }),
258- ... (data .ocs .data .files && { files: data .ocs .data .files }),
259- })
260- this .filesStore .selectFile (data .ocs .data .id )
238+ .then ((nodeId ) => {
239+ this .filesStore .selectFile (nodeId)
261240 this .closeModalUploadFromUrl ()
262241 })
263242 .catch (({ response }) => {
@@ -271,24 +250,14 @@ export default {
271250 return
272251 }
273252
274- await axios . post ( generateOcsUrl ( ' /apps/libresign/api/v1/file ' ), {
253+ await this . filesStore . upload ( {
275254 file: {
276255 path,
277256 },
278257 name: path .match (/ ([^ /] *? )(?:\. [^ . ] * )? $ / )[1 ] ?? ' ' ,
279258 })
280- .then (({ data }) => {
281- this .filesStore .addFile ({
282- nodeId: data .ocs .data .id ,
283- uuid: data .ocs .data .uuid ,
284- name: data .ocs .data .name ,
285- status: data .ocs .data .status ,
286- statusText: data .ocs .data .statusText ,
287- created_at: data .ocs .data .created_at ,
288- ... (data .ocs .data .nodeType && { nodeType: data .ocs .data .nodeType }),
289- ... (data .ocs .data .files && { files: data .ocs .data .files }),
290- })
291- this .filesStore .selectFile (data .ocs .data .id )
259+ .then ((nodeId ) => {
260+ this .filesStore .selectFile (nodeId)
292261 })
293262 .catch (({ response }) => {
294263 showError (response .data .ocs .data .message )
0 commit comments