|
@@ -5,7 +5,6 @@ module.exports = function(crowi, app) {
|
|
|
, Attachment = crowi.model('Attachment')
|
|
, Attachment = crowi.model('Attachment')
|
|
|
, User = crowi.model('User')
|
|
, User = crowi.model('User')
|
|
|
, Page = crowi.model('Page')
|
|
, Page = crowi.model('Page')
|
|
|
- , Promise = require('bluebird')
|
|
|
|
|
, config = crowi.getConfig()
|
|
, config = crowi.getConfig()
|
|
|
, fs = require('fs')
|
|
, fs = require('fs')
|
|
|
, fileUploader = require('../util/fileUploader')(crowi, app)
|
|
, fileUploader = require('../util/fileUploader')(crowi, app)
|
|
@@ -118,19 +117,21 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
|
|
result.page.creator = User.filterToPublicFields(result.page.creator);
|
|
result.page.creator = User.filterToPublicFields(result.page.creator);
|
|
|
result.attachment.creator = User.filterToPublicFields(result.attachment.creator);
|
|
result.attachment.creator = User.filterToPublicFields(result.attachment.creator);
|
|
|
|
|
+
|
|
|
|
|
+ // delete anyway
|
|
|
|
|
+ fs.unlink(tmpPath, function (err) { if (err) { debug('Error while deleting tmp file.'); } });
|
|
|
|
|
+
|
|
|
return res.json(ApiResponse.success(result));
|
|
return res.json(ApiResponse.success(result));
|
|
|
}).catch(function (err) {
|
|
}).catch(function (err) {
|
|
|
debug('Error on saving attachment data', err);
|
|
debug('Error on saving attachment data', err);
|
|
|
// @TODO
|
|
// @TODO
|
|
|
// Remove from S3
|
|
// Remove from S3
|
|
|
|
|
+
|
|
|
|
|
+ // delete anyway
|
|
|
|
|
+ fs.unlink(tmpPath, function (err) { if (err) { debug('Error while deleting tmp file.'); } });
|
|
|
|
|
+
|
|
|
return res.json(ApiResponse.error('Error while uploading.'));
|
|
return res.json(ApiResponse.error('Error while uploading.'));
|
|
|
- }).finally(function() {
|
|
|
|
|
- fs.unlink(tmpPath, function (err) {
|
|
|
|
|
- if (err) {
|
|
|
|
|
- debug('Error while deleting tmp file.');
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ });
|
|
|
;
|
|
;
|
|
|
}).catch(function(err) {
|
|
}).catch(function(err) {
|
|
|
debug('Attachement upload error', err);
|
|
debug('Attachement upload error', err);
|