@social-mail/social-mail-client 1.2.27 → 1.2.28
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 +383 -185
- package/dist/admin/AdminAppIndex.pack.js.map +1 -1
- package/dist/admin/AdminAppIndex.pack.min.js +5 -5
- package/dist/admin/AdminAppIndex.pack.min.js.map +1 -1
- package/dist/common/FileUploader.d.ts +32 -0
- package/dist/common/FileUploader.d.ts.map +1 -0
- package/dist/common/FileUploader.js +133 -0
- package/dist/common/FileUploader.js.map +1 -0
- package/dist/model/model.d.ts +1 -0
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js.map +1 -1
- package/dist/services/files/LocalFileService.d.ts +2 -0
- package/dist/services/files/LocalFileService.d.ts.map +1 -1
- package/dist/services/files/LocalFileService.js +66 -11
- package/dist/services/files/LocalFileService.js.map +1 -1
- package/dist/style/GlobalStyle.js +1 -0
- package/dist/style/GlobalStyle.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/web/AppIndex.pack.js +383 -185
- package/dist/web/AppIndex.pack.js.map +1 -1
- package/dist/web/AppIndex.pack.min.js +5 -5
- package/dist/web/AppIndex.pack.min.js.map +1 -1
- package/node_modules/@web-atoms/core/dist/services/FetchBuilder.d.ts.map +1 -1
- package/node_modules/@web-atoms/core/dist/services/FetchBuilder.js +6 -0
- package/node_modules/@web-atoms/core/dist/services/FetchBuilder.js.map +1 -1
- package/node_modules/@web-atoms/core/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@web-atoms/core/index.js +89 -0
- package/node_modules/@web-atoms/core/package.json +1 -1
- package/node_modules/@web-atoms/core/src/services/FetchBuilder.ts +6 -0
- package/package.json +2 -2
- package/src/common/FileUploader.ts +140 -0
- package/src/model/model.ts +1 -0
- package/src/services/files/LocalFileService.tsx +70 -9
- package/src/style/GlobalStyle.ts +1 -0
|
@@ -13,6 +13,8 @@ import PopupService from "@web-atoms/core/dist/web/services/PopupService";
|
|
|
13
13
|
import { AppFile, IAppFile } from "../../model/model";
|
|
14
14
|
import TaskManager from "@web-atoms/entity/dist/models/TaskManager";
|
|
15
15
|
import EntityService from "../EntityService";
|
|
16
|
+
import FetchBuilder from "@web-atoms/core/dist/services/FetchBuilder";
|
|
17
|
+
import FileUploader, { IUploadRequest, IUploadResult } from "../../common/FileUploader";
|
|
16
18
|
|
|
17
19
|
export const acceptDocumentAndMedia = ".doc, .docx, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, video/*, application/pdf, .pdf, .txt, audio/*, image/*, .csv, text/csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/plain, text/html";
|
|
18
20
|
|
|
@@ -65,6 +67,8 @@ export interface IFileUpload {
|
|
|
65
67
|
@DISingleton()
|
|
66
68
|
export default class LocalFileService extends TaskManager {
|
|
67
69
|
|
|
70
|
+
rateLimit = 4;
|
|
71
|
+
|
|
68
72
|
@Inject
|
|
69
73
|
private app: App;
|
|
70
74
|
|
|
@@ -101,16 +105,74 @@ export default class LocalFileService extends TaskManager {
|
|
|
101
105
|
return hashHex;
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
async uploadFileParts(file: File, extra, cancelToken?: CancelToken, progress?: (n) => void): Promise<IUploadedFile> {
|
|
109
|
+
|
|
110
|
+
let size = file.size;
|
|
111
|
+
const parts = [] as IUploadRequest[];
|
|
112
|
+
const tasks = [] as Promise<IUploadResult>[];
|
|
113
|
+
const maxSize = 4 * 1024 * 1024;
|
|
114
|
+
let start = 0;
|
|
115
|
+
const fud = new FileUploader();
|
|
116
|
+
while(size > 0) {
|
|
117
|
+
const blobSize = Math.min(maxSize, file.size - start);
|
|
118
|
+
const part = new File([file.slice( start, start + blobSize)], "file.dat");
|
|
119
|
+
size -= blobSize;
|
|
120
|
+
start += blobSize;
|
|
121
|
+
const uploadRequest = fud.upload({
|
|
122
|
+
url: "/api/tmp/upload",
|
|
123
|
+
file:part,
|
|
124
|
+
cancelToken,
|
|
125
|
+
progress: () => {
|
|
126
|
+
const done = (parts.reduce((pv, cv) => pv + cv.done, 0) || 0);
|
|
127
|
+
progress?.( done/ parts.length);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
parts.push(uploadRequest);
|
|
131
|
+
tasks.push(uploadRequest.promise);
|
|
132
|
+
}
|
|
133
|
+
const tempUrls = await Promise.all(tasks);
|
|
134
|
+
const tempKeys = tempUrls.map((x) => x.key);
|
|
135
|
+
const name = file.name;
|
|
136
|
+
const { parentID, appFileID, folder } = extra;
|
|
137
|
+
const appFile = await FetchBuilder.post("/api/upload")
|
|
138
|
+
.form("name", name)
|
|
139
|
+
.form("tempKeys", JSON.stringify(tempKeys))
|
|
140
|
+
.form("contentType", file.type)
|
|
141
|
+
.query("parentID", parentID)
|
|
142
|
+
.query("appFileID", appFileID)
|
|
143
|
+
.query("folder", folder)
|
|
144
|
+
.responseAsJson<any>();
|
|
145
|
+
return {
|
|
146
|
+
url: appFile.url,
|
|
147
|
+
downloadUrl: appFile.url,
|
|
148
|
+
file,
|
|
149
|
+
contentType: appFile.contentType,
|
|
150
|
+
fileContentID: appFile.fileContentID,
|
|
151
|
+
appFileID: appFile.appFileID
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
104
155
|
async uploadFile(file: File, extra: any, ct?: CancelToken, progress?: (n) => void): Promise<IUploadedFile> {
|
|
105
|
-
|
|
156
|
+
|
|
157
|
+
let folder = void 0;
|
|
158
|
+
|
|
159
|
+
if (file.webkitRelativePath) {
|
|
160
|
+
const folders = file.webkitRelativePath.split("/");
|
|
161
|
+
folders.pop();
|
|
162
|
+
if (folders.length) {
|
|
163
|
+
folder = folders.join("/");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
106
166
|
|
|
107
167
|
// check if file exists???
|
|
108
168
|
if (typeof extra === "string") {
|
|
109
169
|
extra = JSON.parse(extra);
|
|
110
170
|
}
|
|
111
171
|
|
|
172
|
+
const sha256 = await this.sha256(file);
|
|
173
|
+
|
|
112
174
|
if (extra.parentID) {
|
|
113
|
-
const existing = await this.entityService.query(AppFile, "children", extra.parentID, file.name, sha256)
|
|
175
|
+
const existing = await this.entityService.query(AppFile, "children", extra.parentID, folder ? folder + "/" + file.name : file.name, sha256)
|
|
114
176
|
.firstOrDefault();
|
|
115
177
|
if (existing) {
|
|
116
178
|
const { appFileID, url } = existing;
|
|
@@ -122,6 +184,10 @@ export default class LocalFileService extends TaskManager {
|
|
|
122
184
|
}
|
|
123
185
|
}
|
|
124
186
|
|
|
187
|
+
if (file.size > 4 * 1024 * 1024) {
|
|
188
|
+
return await this.uploadFileParts(file, extra, ct, progress);
|
|
189
|
+
}
|
|
190
|
+
|
|
125
191
|
return new Promise<IUploadedFile>((resolve, reject) => {
|
|
126
192
|
const body = new FormData();
|
|
127
193
|
body.append(file.name, file, file.name);
|
|
@@ -168,13 +234,8 @@ export default class LocalFileService extends TaskManager {
|
|
|
168
234
|
}
|
|
169
235
|
}
|
|
170
236
|
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
folders.pop();
|
|
174
|
-
if (folders.length) {
|
|
175
|
-
const folder = folders.join("/");
|
|
176
|
-
s.append("folder", folder);
|
|
177
|
-
}
|
|
237
|
+
if (folder) {
|
|
238
|
+
s.append("folder", folder);
|
|
178
239
|
}
|
|
179
240
|
|
|
180
241
|
postUrl += "?" + s.toString();
|
package/src/style/GlobalStyle.ts
CHANGED
|
@@ -32,6 +32,7 @@ function addLinkTag(href, integrity?, rel = "stylesheet") {
|
|
|
32
32
|
addLinkTag("https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700&display=swap");
|
|
33
33
|
addLinkTag("https://npm-git.azureedge.net/npm/package/@c8private/fa-icons@6.5.1/css/all.min.css");
|
|
34
34
|
addLinkTag("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0");
|
|
35
|
+
addLinkTag("https://cdn.jsdelivr.net/npm/file-icon-vectors@1.0.0/dist/file-icon-vivid.min.css");
|
|
35
36
|
|
|
36
37
|
styled.css `
|
|
37
38
|
|