Преглед изворни кода

refactor: rename uploadFile to uploadAttachment

mizozobu пре 3 година
родитељ
комит
e76bd78d10

+ 1 - 1
packages/app/src/server/service/attachment.js

@@ -35,7 +35,7 @@ class AttachmentService {
     let attachment;
     try {
       attachment = Attachment.createWithoutSave(pageId, user, fileStream, file.originalname, file.mimetype, file.size, attachmentType);
-      await fileUploadService.uploadFile(fileStream, attachment);
+      await fileUploadService.uploadAttachment(fileStream, attachment);
       await attachment.save();
     }
     catch (err) {

+ 1 - 1
packages/app/src/server/service/file-uploader/aws.ts

@@ -179,7 +179,7 @@ module.exports = (crowi) => {
     return s3.send(new DeleteObjectCommand(params));
   };
 
-  lib.uploadFile = async(fileStream, attachment) => {
+  lib.uploadAttachment = async(fileStream, attachment) => {
     if (!lib.getIsUploadable()) {
       throw new Error('AWS is not configured.');
     }

+ 1 - 1
packages/app/src/server/service/file-uploader/gcs.js

@@ -120,7 +120,7 @@ module.exports = function(crowi) {
     });
   };
 
-  lib.uploadFile = function(fileStream, attachment) {
+  lib.uploadAttachment = function(fileStream, attachment) {
     if (!this.getIsUploadable()) {
       throw new Error('GCS is not configured.');
     }

+ 1 - 1
packages/app/src/server/service/file-uploader/gridfs.js

@@ -90,7 +90,7 @@ module.exports = function(crowi) {
     return lib.doCheckLimit(uploadFileSize, maxFileSize, totalLimit);
   };
 
-  lib.uploadFile = async function(fileStream, attachment) {
+  lib.uploadAttachment = async function(fileStream, attachment) {
     logger.debug(`File uploading: fileName=${attachment.fileName}`);
 
     return AttachmentFile.promisifiedWrite(

+ 1 - 1
packages/app/src/server/service/file-uploader/local.js

@@ -68,7 +68,7 @@ module.exports = function(crowi) {
     return fs.unlinkSync(filePath);
   };
 
-  lib.uploadFile = async function(fileStream, attachment) {
+  lib.uploadAttachment = async function(fileStream, attachment) {
     logger.debug(`File uploading: fileName=${attachment.fileName}`);
 
     const filePath = getFilePathOnStorage(attachment);

+ 1 - 1
packages/app/src/server/service/file-uploader/none.js

@@ -19,7 +19,7 @@ module.exports = function(crowi) {
     throw new Error('not implemented');
   };
 
-  lib.uploadFile = function(filePath, contentType, fileStream, options) {
+  lib.uploadAttachment = function(filePath, contentType, fileStream, options) {
     debug(`File uploading: ${filePath}`);
     throw new Error('not implemented');
   };

+ 2 - 2
packages/app/src/server/service/g2g-transfer.ts

@@ -160,7 +160,7 @@ const hasWritePermission = async(crowi: any): Promise<boolean> => {
   };
 
   try {
-    await fileUploadService.uploadFile(fileStream, attachment);
+    await fileUploadService.uploadAttachment(fileStream, attachment);
     // TODO: remove tmp file
   }
   catch (err) {
@@ -538,7 +538,7 @@ export class G2GTransferReceiverService implements Receiver {
   public async receiveAttachment(content: Readable, attachmentMap): Promise<void> {
     // TODO: test with S3, local
     const { fileUploadService } = this.crowi;
-    return fileUploadService.uploadFile(content, attachmentMap);
+    return fileUploadService.uploadAttachment(content, attachmentMap);
   }
 
   /**