feat: Files uploadFailedFirst size > 80MB text done.

This commit is contained in:
chiayin
2024-01-17 11:20:36 +08:00
parent 75bbcd07ab
commit a9f991a715
2 changed files with 6 additions and 1 deletions

View File

@@ -177,7 +177,7 @@ export async function uploadFailedFirst(failureType, failureMsg) {
let value = ''; let value = '';
switch (failureType) { switch (failureType) {
case 'size': case 'size':
value = '檔案大小不可超過 90MB'; value = 'File size exceeds 90MB.';
break; break;
case 'encoding': case 'encoding':
value = 'not in UTF-8'; value = 'not in UTF-8';

View File

@@ -123,10 +123,12 @@ export default defineStore('filesStore', {
uploadloader(); // 進度條 uploadloader(); // 進度條
try { try {
const response = await axios.post(api, fromData, config); const response = await axios.post(api, fromData, config);
console.log('第一階段 response:', response);
this.uploadId = response.data.id; this.uploadId = response.data.id;
this.$router.push({name: 'Upload'}); this.$router.push({name: 'Upload'});
Swal.close(); // 關閉進度條 Swal.close(); // 關閉進度條
} catch(error) { } catch(error) {
console.log('第一階段 error:', error);
if(error.response.status === 422) { if(error.response.status === 422) {
// msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv' // msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv'
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix' // type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
@@ -162,6 +164,7 @@ export default defineStore('filesStore', {
uploadloader(); // 進度條 uploadloader(); // 進度條
try { try {
const response = await axios.post(api, data); const response = await axios.post(api, data);
console.log('第二階段 response:', response);
this.uploadLogId = await response.data.id; this.uploadLogId = await response.data.id;
await Swal.close(); // 關閉進度條 await Swal.close(); // 關閉進度條
@@ -169,6 +172,8 @@ export default defineStore('filesStore', {
await uploadSuccess(); await uploadSuccess();
this.$router.push({name: 'Files'}); this.$router.push({name: 'Files'});
} catch(error) { } catch(error) {
console.log('第二階段 error:', error);
if(error.response.status === 422) { if(error.response.status === 422) {
uploadFailedSecond(error.response.data.detail[0].type, error.response.data.detail[0].msg); uploadFailedSecond(error.response.data.detail[0].type, error.response.data.detail[0].msg);
} else { } else {