@nger/fk-upload 1.0.26 → 1.0.29
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.
@@ -70,15 +70,17 @@ let TaskService = class TaskService {
|
|
70
70
|
async createDownLoadTask(url, fkLoginId, topicId) {
|
71
71
|
const hash = await (0, multihashing_async_1.default)(Buffer.from(url), 'sha1', 16);
|
72
72
|
const cid = new cids_1.default(1, 'raw', hash, 'base64');
|
73
|
-
|
73
|
+
let filename = encodeURIComponent(cid.toString('base64'));
|
74
74
|
const _url = new URL(url);
|
75
75
|
const filePath = _url.pathname;
|
76
|
-
|
76
|
+
let ext = (0, path_1.extname)(filePath);
|
77
|
+
console.log({ filePath, ext });
|
78
|
+
filename += ext === '.' ? '.mp4' : ext;
|
77
79
|
const task = new entities_1.FkDownloadTaskEntity();
|
78
80
|
const root = this.injector.get(core_1.APP_ROOT);
|
79
81
|
(0, fs_extra_1.ensureDirSync)((0, path_1.join)(root, 'attachments/fk-upload'));
|
80
|
-
const path = (0, path_1.join)(root, 'attachments/fk-upload',
|
81
|
-
task.filename = filename
|
82
|
+
const path = (0, path_1.join)(root, 'attachments/fk-upload', filename);
|
83
|
+
task.filename = filename;
|
82
84
|
task.url = url;
|
83
85
|
task.loginId = fkLoginId;
|
84
86
|
task.totalSize = 0;
|
@@ -159,6 +161,10 @@ let TaskService = class TaskService {
|
|
159
161
|
if (err)
|
160
162
|
return fail();
|
161
163
|
if (reply) {
|
164
|
+
const isExist = await this.db.manager.find(entities_1.FkDownloadTaskEntity, { where: { filename: task.filename } });
|
165
|
+
if (!isExist) {
|
166
|
+
return complete();
|
167
|
+
}
|
162
168
|
const taskIndex = Number(reply); // next
|
163
169
|
const isComplete = task.complete && task.index === taskIndex;
|
164
170
|
const isShouldRunning = isComplete || (!isComplete && task.index == taskIndex);
|
@@ -170,9 +176,9 @@ let TaskService = class TaskService {
|
|
170
176
|
formdata.append('isFreeVer', this.encodeURIComponent(false));
|
171
177
|
formdata.append('aid', this.encodeURIComponent(task.aid));
|
172
178
|
formdata.append('folderId', this.encodeURIComponent(task.folderId));
|
173
|
-
formdata.append('fileName',
|
179
|
+
formdata.append('fileName', task.filename);
|
174
180
|
formdata.append(`totalSize`, this.encodeURIComponent(task.total));
|
175
|
-
formdata.append(`fileMd5`,
|
181
|
+
formdata.append(`fileMd5`, task.fileMd5);
|
176
182
|
formdata.append('index', this.encodeURIComponent(task.index));
|
177
183
|
formdata.append('chunkSize', this.encodeURIComponent(task.splitSize));
|
178
184
|
formdata.append('totalChunks', this.encodeURIComponent(task.totalChunks));
|
@@ -180,7 +186,7 @@ let TaskService = class TaskService {
|
|
180
186
|
const bssInfo = {
|
181
187
|
fromSite: true, siteId: 0, groupId: 0, fileSizeLimit: 1024
|
182
188
|
};
|
183
|
-
formdata.append('bssInfo',
|
189
|
+
formdata.append('bssInfo', JSON.stringify(bssInfo));
|
184
190
|
const headers = formdata.getHeaders();
|
185
191
|
const uploadResult = await axios_1.default.post(task.uploadUrl, formdata, {
|
186
192
|
headers: {
|