File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,12 @@ Sets the `Expires` header on the uploaded files.
169
169
170
170
* Default:* ` Mon Dec 31 2029 21:00:00 GMT-0300 (CLST) `
171
171
172
+ ### defaultMimeType
173
+
174
+ Sets the default mime type, used when it cannot be determined from the file extension.
175
+
176
+ * Default:* ` application/octet-stream `
177
+
172
178
## Prerequisites
173
179
174
180
The following properties are expected to be present on the deployment ` context ` object:
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ module.exports = CoreObject.extend({
92
92
var cacheControl = options . cacheControl ;
93
93
var expires = options . expires ;
94
94
95
+ mime . default_type = options . defaultMimeType || mime . lookup ( 'bin' ) ;
96
+
95
97
return filePaths . map ( function ( filePath ) {
96
98
var basePath = path . join ( cwd , filePath ) ;
97
99
var data = fs . readFileSync ( basePath ) ;
Original file line number Diff line number Diff line change
1
+ <p>Some HTML</p>
Original file line number Diff line number Diff line change @@ -146,6 +146,47 @@ describe('s3', function() {
146
146
assert . equal ( s3Params . Expires , '2010' ) ;
147
147
} ) ;
148
148
} ) ;
149
+
150
+ it ( 'sets the content type using defaultMimeType' , function ( ) {
151
+ var s3Params ;
152
+ s3Client . putObject = function ( params , cb ) {
153
+ s3Params = params ;
154
+ cb ( ) ;
155
+ } ;
156
+
157
+ var options = {
158
+ filePaths : [ 'index' ] ,
159
+ cwd : process . cwd ( ) + '/tests/fixtures/dist' ,
160
+ defaultMimeType : 'text/html'
161
+ } ;
162
+
163
+ var promises = subject . upload ( options ) ;
164
+
165
+ return assert . isFulfilled ( promises )
166
+ . then ( function ( ) {
167
+ assert . equal ( s3Params . ContentType , 'text/html; charset=utf-8' ) ;
168
+ } ) ;
169
+ } ) ;
170
+
171
+ it ( 'sets the content type to the default' , function ( ) {
172
+ var s3Params ;
173
+ s3Client . putObject = function ( params , cb ) {
174
+ s3Params = params ;
175
+ cb ( ) ;
176
+ } ;
177
+
178
+ var options = {
179
+ filePaths : [ 'index' ] ,
180
+ cwd : process . cwd ( ) + '/tests/fixtures/dist'
181
+ } ;
182
+
183
+ var promises = subject . upload ( options ) ;
184
+
185
+ return assert . isFulfilled ( promises )
186
+ . then ( function ( ) {
187
+ assert . equal ( s3Params . ContentType , 'application/octet-stream' ) ;
188
+ } ) ;
189
+ } ) ;
149
190
} ) ;
150
191
151
192
describe ( 'with a manifestPath specified' , function ( ) {
You can’t perform that action at this time.
0 commit comments