Commit 9fd5bb06 authored by nanahira's avatar nanahira

logging

parent 66d14f36
Pipeline #17468 passed with stages
in 2 minutes and 25 seconds
...@@ -134,6 +134,7 @@ export class OneTwoThreeService extends MiddlewareService { ...@@ -134,6 +134,7 @@ export class OneTwoThreeService extends MiddlewareService {
async upload(info) { async upload(info) {
try { try {
const fileName = info.getFilename(); const fileName = info.getFilename();
this.log(`Uploading ${info.url} as ${fileName}`);
const uploadReq = await lastValueFrom( const uploadReq = await lastValueFrom(
this.http.post<OTTResponse<UploadReq>>( this.http.post<OTTResponse<UploadReq>>(
'https://www.123pan.com/api/file/upload_request', 'https://www.123pan.com/api/file/upload_request',
...@@ -161,9 +162,11 @@ export class OneTwoThreeService extends MiddlewareService { ...@@ -161,9 +162,11 @@ export class OneTwoThreeService extends MiddlewareService {
if (!uploadReq.data.data.AccessKeyId) { if (!uploadReq.data.data.AccessKeyId) {
// already uploaded // already uploaded
// return JSON.stringify(adaptFileInfo(uploadReq.data.data.Info)); // return JSON.stringify(adaptFileInfo(uploadReq.data.data.Info));
return await this.getDownloadUrl( const existing = await this.getDownloadUrl(
adaptFileInfo(uploadReq.data.data.Info), adaptFileInfo(uploadReq.data.data.Info),
); );
this.log(`File ${fileName} exists as ${existing}, skipping.`);
return existing;
} }
const s3 = new S3Client({ const s3 = new S3Client({
...@@ -200,7 +203,11 @@ export class OneTwoThreeService extends MiddlewareService { ...@@ -200,7 +203,11 @@ export class OneTwoThreeService extends MiddlewareService {
}, },
), ),
); );
return await this.getDownloadUrl(adaptFileInfo(uploadReq.data.data.Info)); const uploadedUrl = await this.getDownloadUrl(
adaptFileInfo(completeReq.data.data.Info),
);
this.log(`Uploaded ${fileName} as ${uploadedUrl}`);
return uploadedUrl;
} catch (e) { } catch (e) {
this.error(`Upload failed: ${e.message}`); this.error(`Upload failed: ${e.message}`);
throw new BlankReturnMessageDto(500, e.message).toException(); throw new BlankReturnMessageDto(500, e.message).toException();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment