@nger/fk-upload 1.0.29 → 1.0.32

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
  }
@@ -60,8 +60,8 @@ let TaskService = class TaskService {
60
60
  this.redis.set(filename, `0`);
61
61
  }
62
62
  async addEffectTask(task) {
63
- const content = Buffer.from(JSON.stringify(task));
64
- await this.rabbit.send('@nger/fk-upload/effect-task', content);
63
+ // const content = Buffer.from(JSON.stringify(task));
64
+ // await this.rabbit.send('@nger/fk-upload/effect-task', content)
65
65
  }
66
66
  async addScheduleTask(task) {
67
67
  const content = Buffer.from(JSON.stringify(task));
@@ -74,7 +74,6 @@ let TaskService = class TaskService {
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
77
  filename += ext === '.' ? '.mp4' : ext;
79
78
  const task = new entities_1.FkDownloadTaskEntity();
80
79
  const root = this.injector.get(core_1.APP_ROOT);
@@ -204,55 +203,59 @@ let TaskService = class TaskService {
204
203
  total: task.total
205
204
  }
206
205
  });
207
- this.redis.set(task.filename, `${task.index + 1}`);
208
- if (data) {
209
- // fullDownUrl
210
- const downUrl = data.fullDownUrl;
211
- if (downUrl) {
212
- const fullUrl = downUrl.startsWith('http') ? downUrl : `https:` + downUrl;
213
- console.log({ data, task });
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
- this.ws.send({
228
- action: `@nger/fk-upload/uploading`,
229
- data: {
230
- uploadSize: task.end,
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({
231
239
  filename: task.filename,
232
- total: task.total,
233
- uploadUrl: fullUrl
234
- }
235
- });
236
- this.addEffectTask({
237
- filename: task.filename,
238
- uploadUrl: fullUrl,
239
- topicId: task.topicId
240
- });
241
- this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
242
- status: 2,
243
- uploadUrl: fullUrl,
244
- uploadSize: task.total
245
- }).then(() => complete()).catch(() => fail());
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
+ }
246
254
  }
247
255
  else {
248
- this.db.manager.update(entities_1.FkDownloadTaskEntity, task.filename, {
249
- uploadSize: task.end
250
- }).then(() => complete()).catch(() => fail());
256
+ console.log(`data is empty`, uploadResult);
251
257
  }
252
- }
253
- else {
254
- fail();
255
- }
258
+ });
256
259
  }
257
260
  else {
258
261
  fail();
@@ -332,6 +335,7 @@ let TaskService = class TaskService {
332
335
  return `https://${token.url}/${token.visitType}/${token.app}/advance?cmd=${token.cmd}&token=${token.token}`;
333
336
  }
334
337
  }
338
+ async reUploadTask() { }
335
339
  async startUploadTask(filename) {
336
340
  const task = await this.db.manager.findOne(entities_1.FkDownloadTaskEntity, { where: { filename } });
337
341
  if (task && task.status === 1) {
@@ -376,8 +380,8 @@ let TaskService = class TaskService {
376
380
  const { delayTime, splitSize, uploadedSize } = data;
377
381
  const uploadUrl = this.getUploadUrl(accessToken, false);
378
382
  const totalChunks = Math.ceil((task.totalSize) / splitSize);
379
- let start = 0;
380
- let index = 0;
383
+ let start = uploadedSize;
384
+ let index = Math.ceil(uploadedSize / splitSize);
381
385
  let complete = false;
382
386
  this.beginUploadTask(task.filename);
383
387
  do {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nger/fk-upload",
3
- "version": "1.0.29",
3
+ "version": "1.0.32",
4
4
  "description": "",
5
5
  "main": "dist/core.js",
6
6
  "types": "dist/core.d.ts",