@nger/fk-upload 1.0.28 → 1.0.31
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.
@@ -62,6 +62,7 @@ export declare class TaskService {
|
|
62
62
|
private getUploadInfourl;
|
63
63
|
private encodeURIComponent;
|
64
64
|
private getUploadUrl;
|
65
|
+
reUploadTask(): Promise<void>;
|
65
66
|
startUploadTask(filename: string): Promise<void>;
|
66
67
|
download(task: DownloadTask): Observable<DownloadTask>;
|
67
68
|
}
|
@@ -70,15 +70,16 @@ 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
|
+
filename += ext === '.' ? '.mp4' : ext;
|
77
78
|
const task = new entities_1.FkDownloadTaskEntity();
|
78
79
|
const root = this.injector.get(core_1.APP_ROOT);
|
79
80
|
(0, fs_extra_1.ensureDirSync)((0, path_1.join)(root, 'attachments/fk-upload'));
|
80
|
-
const path = (0, path_1.join)(root, 'attachments/fk-upload', filename
|
81
|
-
task.filename = filename
|
81
|
+
const path = (0, path_1.join)(root, 'attachments/fk-upload', filename);
|
82
|
+
task.filename = filename;
|
82
83
|
task.url = url;
|
83
84
|
task.loginId = fkLoginId;
|
84
85
|
task.totalSize = 0;
|
@@ -202,55 +203,59 @@ let TaskService = class TaskService {
|
|
202
203
|
total: task.total
|
203
204
|
}
|
204
205
|
});
|
205
|
-
this.redis.set(task.filename, `${task.index + 1}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
const
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
206
|
+
this.redis.set(task.filename, `${task.index + 1}`, (err) => {
|
207
|
+
if (err)
|
208
|
+
return fail();
|
209
|
+
if (data) {
|
210
|
+
// fullDownUrl
|
211
|
+
const downUrl = data.path;
|
212
|
+
if (downUrl) {
|
213
|
+
const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
|
214
|
+
axios_1.default.post(`https://smr00.vip.webportal.top/ajax/advanceUpload.jsp?cmd=_report&_TOKEN=${task.token}`, this.encodeURIComponent({
|
215
|
+
type: 1,
|
216
|
+
size: task.total,
|
217
|
+
time: NaN,
|
218
|
+
flag: true,
|
219
|
+
name: task.filename
|
220
|
+
}), {
|
221
|
+
headers: {
|
222
|
+
[`Content-Type`]: `application/x-www-form-urlencoded; charset=UTF-8`,
|
223
|
+
Cookie: task.cookies
|
224
|
+
}
|
225
|
+
});
|
226
|
+
this.redis.del(task.filename, () => {
|
227
|
+
complete();
|
228
|
+
});
|
229
|
+
this.ws.send({
|
230
|
+
action: `@nger/fk-upload/uploading`,
|
231
|
+
data: {
|
232
|
+
uploadSize: task.end,
|
233
|
+
filename: task.filename,
|
234
|
+
total: task.total,
|
235
|
+
uploadUrl: fullUrl
|
236
|
+
}
|
237
|
+
});
|
238
|
+
this.addEffectTask({
|
229
239
|
filename: task.filename,
|
230
|
-
|
231
|
-
|
232
|
-
}
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
}
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
}
|
240
|
+
uploadUrl: fullUrl,
|
241
|
+
topicId: task.topicId
|
242
|
+
});
|
243
|
+
this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
|
244
|
+
status: 2,
|
245
|
+
uploadUrl: fullUrl,
|
246
|
+
uploadSize: task.total
|
247
|
+
});
|
248
|
+
}
|
249
|
+
else {
|
250
|
+
this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
|
251
|
+
uploadSize: task.end
|
252
|
+
});
|
253
|
+
}
|
244
254
|
}
|
245
255
|
else {
|
246
|
-
|
247
|
-
uploadSize: task.end
|
248
|
-
}).then(() => complete()).catch(() => fail());
|
256
|
+
console.log(`data is empty`, uploadResult);
|
249
257
|
}
|
250
|
-
}
|
251
|
-
else {
|
252
|
-
fail();
|
253
|
-
}
|
258
|
+
});
|
254
259
|
}
|
255
260
|
else {
|
256
261
|
fail();
|
@@ -330,6 +335,7 @@ let TaskService = class TaskService {
|
|
330
335
|
return `https://${token.url}/${token.visitType}/${token.app}/advance?cmd=${token.cmd}&token=${token.token}`;
|
331
336
|
}
|
332
337
|
}
|
338
|
+
async reUploadTask() { }
|
333
339
|
async startUploadTask(filename) {
|
334
340
|
const task = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename } });
|
335
341
|
if (task && task.status === 1) {
|
@@ -374,8 +380,8 @@ let TaskService = class TaskService {
|
|
374
380
|
const { delayTime, splitSize, uploadedSize } = data;
|
375
381
|
const uploadUrl = this.getUploadUrl(accessToken, false);
|
376
382
|
const totalChunks = Math.ceil((task.totalSize) / splitSize);
|
377
|
-
let start =
|
378
|
-
let index =
|
383
|
+
let start = uploadedSize;
|
384
|
+
let index = Math.ceil(uploadedSize / splitSize);
|
379
385
|
let complete = false;
|
380
386
|
this.beginUploadTask(task.filename);
|
381
387
|
do {
|