Yuki Takei преди 5 години
родител
ревизия
5d66f586fe
променени са 2 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 1 1
      src/server/routes/attachment.js
  2. 3 2
      src/server/service/attachment.js

+ 1 - 1
src/server/routes/attachment.js

@@ -233,7 +233,7 @@ module.exports = function(crowi, app) {
   }
   }
 
 
   async function removeAttachment(attachmentId) {
   async function removeAttachment(attachmentId) {
-    const fileUploadService = crowi;
+    const { fileUploadService } = crowi;
 
 
     // retrieve data from DB to get a completely populated instance
     // retrieve data from DB to get a completely populated instance
     const attachment = await Attachment.findById(attachmentId);
     const attachment = await Attachment.findById(attachmentId);

+ 3 - 2
src/server/service/attachment.js

@@ -13,9 +13,10 @@ class AttachmentService {
   }
   }
 
 
   async createAttachment(file, user, pageId = null) {
   async createAttachment(file, user, pageId = null) {
+    const { fileUploadService } = this.crowi;
 
 
     // check limit
     // check limit
-    const res = await this.fileUploadService.checkLimit(file.size);
+    const res = await fileUploadService.checkLimit(file.size);
     if (!res.isUploadable) {
     if (!res.isUploadable) {
       throw new Error(res.errorMessage);
       throw new Error(res.errorMessage);
     }
     }
@@ -30,7 +31,7 @@ class AttachmentService {
     let attachment;
     let attachment;
     try {
     try {
       attachment = Attachment.createWithoutSave(pageId, user, fileStream, file.originalname, file.mimetype, file.size);
       attachment = Attachment.createWithoutSave(pageId, user, fileStream, file.originalname, file.mimetype, file.size);
-      await this.fileUploadService.uploadFile(fileStream, attachment);
+      await fileUploadService.uploadFile(fileStream, attachment);
       await attachment.save();
       await attachment.save();
     }
     }
     catch (err) {
     catch (err) {