fix: double upload attachment
This commit is contained in:
parent
b58ed78929
commit
c9f582359c
1 changed files with 24 additions and 17 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
import { Dialog, QSelect, Notify, QNotifyCreateOptions } from 'quasar';
|
import { Dialog, QSelect, Notify, QNotifyCreateOptions } from 'quasar';
|
||||||
import GlobalDialog from 'components/GlobalDialog.vue';
|
import { Ref, ref } from 'vue';
|
||||||
import DialogDuplicateData from 'components/DialogDuplicateData.vue';
|
import axios, { AxiosInstance, AxiosProgressEvent } from 'axios';
|
||||||
import { ComposerTranslation } from 'vue-i18n';
|
import { ComposerTranslation } from 'vue-i18n';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { Ref, ref } from 'vue';
|
|
||||||
import { getRole } from 'src/services/keycloak';
|
import { getRole } from 'src/services/keycloak';
|
||||||
import { AxiosInstance, AxiosProgressEvent } from 'axios';
|
|
||||||
|
import GlobalDialog from 'components/GlobalDialog.vue';
|
||||||
|
import DialogDuplicateData from 'components/DialogDuplicateData.vue';
|
||||||
|
|
||||||
export const baseUrl = import.meta.env.VITE_API_BASE_URL;
|
export const baseUrl = import.meta.env.VITE_API_BASE_URL;
|
||||||
|
|
||||||
|
|
@ -291,21 +293,26 @@ export function manageAttachment(
|
||||||
onUploadProgress?: (e: AxiosProgressEvent) => void;
|
onUploadProgress?: (e: AxiosProgressEvent) => void;
|
||||||
abortController?: AbortController;
|
abortController?: AbortController;
|
||||||
}) => {
|
}) => {
|
||||||
const res = await api.put(
|
const urlRes = await api.put(
|
||||||
`/${base}/${opts.parentId}/attachment/${opts.name}`,
|
`/${base}/${opts.parentId}/attachment/${opts.name}`,
|
||||||
opts.file,
|
|
||||||
{
|
|
||||||
headers: { 'Content-Type': opts.file.type },
|
|
||||||
onUploadProgress: opts.onUploadProgress
|
|
||||||
? opts.onUploadProgress
|
|
||||||
: option?.onUploadProgress
|
|
||||||
? option.onUploadProgress
|
|
||||||
: (e) => console.log(e),
|
|
||||||
signal: opts.abortController?.signal,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
if (res.status < 400) return true;
|
|
||||||
return false;
|
if (urlRes.status >= 400) return false;
|
||||||
|
|
||||||
|
// NOTE: Must use axios instance or else CORS error.
|
||||||
|
const uploadRes = await axios.put(urlRes.data, opts.file, {
|
||||||
|
headers: { 'Content-Type': opts.file.type },
|
||||||
|
onUploadProgress: opts.onUploadProgress
|
||||||
|
? opts.onUploadProgress
|
||||||
|
: option?.onUploadProgress
|
||||||
|
? option.onUploadProgress
|
||||||
|
: (e) => console.log(e),
|
||||||
|
signal: opts.abortController?.signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (uploadRes.status >= 400) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
delAttachment: async (opts: { parentId: string; name: string }) => {
|
delAttachment: async (opts: { parentId: string; name: string }) => {
|
||||||
const res = await api.delete(
|
const res = await api.delete(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue