@social-mail/social-mail-client 1.8.324 → 1.8.325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/AdminAppIndex.pack.js +5 -10
- package/dist/admin/AdminAppIndex.pack.js.map +1 -1
- package/dist/admin/AdminAppIndex.pack.min.js +1 -1
- package/dist/admin/AdminAppIndex.pack.min.js.map +1 -1
- package/dist/common/FileUploader.d.ts +0 -1
- package/dist/common/FileUploader.d.ts.map +1 -1
- package/dist/common/FileUploader.js +0 -5
- package/dist/common/FileUploader.js.map +1 -1
- package/dist/services/files/LocalFileService.d.ts +2 -2
- package/dist/services/files/LocalFileService.d.ts.map +1 -1
- package/dist/services/files/LocalFileService.js +5 -5
- package/dist/services/files/LocalFileService.js.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.js +5 -10
- package/dist/site-editor-app/SiteEditorApp.pack.js.map +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.min.js +1 -1
- package/dist/site-editor-app/SiteEditorApp.pack.min.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/web/AppIndex.pack.js +5 -10
- package/dist/web/AppIndex.pack.js.map +1 -1
- package/dist/web/AppIndex.pack.min.js +1 -1
- package/dist/web/AppIndex.pack.min.js.map +1 -1
- package/package.json +1 -1
- package/src/common/FileUploader.ts +1 -6
- package/src/services/files/LocalFileService.tsx +5 -6
package/package.json
CHANGED
|
@@ -20,7 +20,6 @@ export interface IUploadRequest {
|
|
|
20
20
|
export interface IUploadRequestParams {
|
|
21
21
|
file: File,
|
|
22
22
|
url: string,
|
|
23
|
-
sha256?: string,
|
|
24
23
|
extra?: any,
|
|
25
24
|
folder?: string,
|
|
26
25
|
cancelToken?: CancelToken,
|
|
@@ -64,9 +63,6 @@ export default class FileUploader {
|
|
|
64
63
|
|
|
65
64
|
private async tryUpload3(req: IUploadRequestParams) {
|
|
66
65
|
let lastError;
|
|
67
|
-
if(!req.sha256) {
|
|
68
|
-
req.sha256 = await this.sha256(req.file);
|
|
69
|
-
}
|
|
70
66
|
for (let index = 0; index < 3; index++) {
|
|
71
67
|
try {
|
|
72
68
|
return await this.tryUpload(req);
|
|
@@ -77,12 +73,11 @@ export default class FileUploader {
|
|
|
77
73
|
throw lastError;
|
|
78
74
|
}
|
|
79
75
|
|
|
80
|
-
private tryUpload({ file, url,
|
|
76
|
+
private tryUpload({ file, url, extra, folder, cancelToken, progress }: IUploadRequestParams) {
|
|
81
77
|
return new Promise<IUploadResult>((resolve, reject) => {
|
|
82
78
|
|
|
83
79
|
const body = new FormData();
|
|
84
80
|
body.append(file.name, file, file.name);
|
|
85
|
-
body.append("sha256", sha256);
|
|
86
81
|
const xhr = new XMLHttpRequest();
|
|
87
82
|
const onError = () => {
|
|
88
83
|
reject(new Error(xhr.responseText || "Error"));
|
|
@@ -77,7 +77,7 @@ export default class LocalFileService extends TaskManager {
|
|
|
77
77
|
return detail.files;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
async
|
|
80
|
+
async getSha256(blob: Blob) {
|
|
81
81
|
const msgBuffer = await blob.arrayBuffer();
|
|
82
82
|
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
|
|
83
83
|
|
|
@@ -88,7 +88,7 @@ export default class LocalFileService extends TaskManager {
|
|
|
88
88
|
return hashHex;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
async uploadFileParts(file: File, extra, cancelToken?: CancelToken, progress?: (n) => void): Promise<IUploadedFile> {
|
|
91
|
+
async uploadFileParts(file: File, extra, sha256, cancelToken?: CancelToken, progress?: (n) => void): Promise<IUploadedFile> {
|
|
92
92
|
|
|
93
93
|
let size = file.size;
|
|
94
94
|
const parts = [] as IUploadRequest[];
|
|
@@ -119,6 +119,7 @@ export default class LocalFileService extends TaskManager {
|
|
|
119
119
|
const { parentID, appFileID, folder } = extra;
|
|
120
120
|
const appFile = await FetchBuilder.post(apiPath("/api/upload"))
|
|
121
121
|
.form("name", name)
|
|
122
|
+
.form("sha256", sha256)
|
|
122
123
|
.form("tempKeys", JSON.stringify(tempKeys))
|
|
123
124
|
.form("contentType", file.type)
|
|
124
125
|
.query("parentID", parentID)
|
|
@@ -152,9 +153,7 @@ export default class LocalFileService extends TaskManager {
|
|
|
152
153
|
extra = JSON.parse(extra);
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const sha256 = await this.sha256(file);
|
|
156
|
+
const sha256 = await this.getSha256(file);
|
|
158
157
|
|
|
159
158
|
if (extra?.parentID) {
|
|
160
159
|
const existing = await this.entityService.query(AppFile, "children", extra.parentID, folder ? folder + "/" + file.name : file.name, sha256)
|
|
@@ -174,7 +173,7 @@ export default class LocalFileService extends TaskManager {
|
|
|
174
173
|
extra ??= {};
|
|
175
174
|
extra.folder = folder;
|
|
176
175
|
}
|
|
177
|
-
return await this.uploadFileParts(file, extra, ct, progress);
|
|
176
|
+
return await this.uploadFileParts(file, extra, sha256, ct, progress);
|
|
178
177
|
}
|
|
179
178
|
|
|
180
179
|
return new Promise<IUploadedFile>((resolve, reject) => {
|