File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -144,5 +144,26 @@ S3Adapter.prototype.getFileLocation = function(config, filename) {
144
144
return ( config . mount + '/files/' + config . applicationId + '/' + filename ) ;
145
145
}
146
146
147
+ S3Adapter . prototype . getFileStream = async function ( filename , req , res ) {
148
+ const params = {
149
+ Key : this . _bucketPrefix + filename ,
150
+ Range : req . get ( 'Range' ) ,
151
+ } ;
152
+ await this . createBucket ( ) ;
153
+ this . _s3Client . getObject ( params , ( error , data ) => {
154
+ if ( error !== null || ( data && ! data . Body ) ) {
155
+ return res . sendStatus ( 404 ) ;
156
+ }
157
+ res . writeHead ( 206 , {
158
+ 'Accept-Ranges' : data . AcceptRanges ,
159
+ 'Content-Length' : data . ContentLength ,
160
+ 'Content-Range' : data . ContentRange ,
161
+ 'Content-Type' : data . ContentType ,
162
+ } ) ;
163
+ res . write ( data . Body ) ;
164
+ res . end ( ) ;
165
+ } ) ;
166
+ }
167
+
147
168
module . exports = S3Adapter ;
148
169
module . exports . default = S3Adapter ;
You can’t perform that action at this time.
0 commit comments