@@ -66,41 +66,15 @@ module.exports = [
66
66
fileServiceUrl += '/' ;
67
67
}
68
68
69
- const fileTransferPromise = new Promise ( ( accept , reject ) => {
70
- if ( process . env . NODE_ENV !== 'development' || config . get ( 'enableFileUpload' ) === 'true' ) {
71
- // get pre-signed Url
72
- req . log . debug ( 'requesting presigned Url' ) ;
73
- httpClient . post ( `${ fileServiceUrl } uploadurl/` , {
74
- param : {
75
- filePath,
76
- contentType : data . contentType ,
77
- isPublic : false ,
78
- } ,
79
- // Promise.resolve({
80
- // status: 200,
81
- // data: {
82
- // result: {
83
- // status: 200,
84
- // },
85
- // },
86
- } ) . then ( ( resp ) => {
87
- req . log . debug ( 'Presigned Url resp: ' , JSON . stringify ( resp . data , null , 2 ) ) ;
88
- if ( resp . status !== 200 || resp . data . result . status !== 200 ) {
89
- return reject ( new Error ( resp . data . result . message ) ) ;
90
- }
91
- const sourceBucket = data . s3Bucket ;
92
- const sourceKey = data . filePath ;
93
- const destBucket = config . get ( 'attachmentsS3Bucket' ) ;
94
- const destKey = filePath ;
69
+ const sourceBucket = data . s3Bucket ;
70
+ const sourceKey = data . filePath ;
71
+ const destBucket = config . get ( 'attachmentsS3Bucket' ) ;
72
+ const destKey = filePath ;
95
73
96
- req . log . debug ( 'Moving s3 file' ) ;
97
- // transfer file
98
- return util . s3FileTransfer ( req , sourceBucket , sourceKey , destBucket , destKey ) ;
99
- } ) . then ( ( ) => accept ( ) ) . catch ( reject ) ;
100
- } else {
101
- accept ( ) ;
102
- }
103
- } ) ;
74
+ // don't actually transfer file in development mode if file uploading is disabled, so we can test this endpoint
75
+ const fileTransferPromise = ( process . env . NODE_ENV !== 'development' || config . get ( 'enableFileUpload' ) === 'true' )
76
+ ? util . s3FileTransfer ( req , sourceBucket , sourceKey , destBucket , destKey )
77
+ : Promise . resolve ( ) ;
104
78
105
79
fileTransferPromise . then ( ( ) => {
106
80
// file copied to final destination, create DB record
0 commit comments