File tree Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Expand file tree Collapse file tree 4 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ var Promise = require('ember-cli/lib/ext/promise');
4
4
var fs = require ( 'fs' ) ;
5
5
var path = require ( 'path' ) ;
6
6
var readFile = Promise . denodeify ( fs . readFile ) ;
7
+ var mime = require ( 'mime-types' ) ;
7
8
8
9
function headObject ( client , params ) {
9
10
return new Promise ( function ( resolve , reject ) {
@@ -47,7 +48,7 @@ module.exports = CoreObject.extend({
47
48
Bucket : bucket ,
48
49
Key : key ,
49
50
ACL : acl ,
50
- ContentType : 'text/html' ,
51
+ ContentType : mime . lookup ( options . filePath ) || 'text/html' ,
51
52
CacheControl : 'max-age=0, no-cache'
52
53
}
53
54
Original file line number Diff line number Diff line change 51
51
"aws-sdk" : " ^2.1.48" ,
52
52
"core-object" : " ^1.1.0" ,
53
53
"ember-cli-babel" : " ^5.1.3" ,
54
- "ember-cli-deploy-plugin" : " ^0.2.1"
54
+ "ember-cli-deploy-plugin" : " ^0.2.1" ,
55
+ "mime-types" : " ^2.1.9"
55
56
},
56
57
"ember-addon" : {
57
58
"configPath" : " tests/dummy/config"
Original file line number Diff line number Diff line change @@ -124,6 +124,19 @@ describe('s3', function() {
124
124
} ) ;
125
125
} ) ;
126
126
127
+ it ( 'detects `filePattern` other than `index.html` in order to customize ContentType' , function ( ) {
128
+ var filePath = 'tests/unit/fixtures/test.tar' ;
129
+
130
+ options . filePath = filePath ;
131
+ var promise = subject . upload ( options ) ;
132
+
133
+ return assert . isFulfilled ( promise )
134
+ . then ( function ( ) {
135
+ var expectedContentType = 'application/x-tar' ;
136
+ assert . equal ( s3Params . ContentType , expectedContentType , 'contentType is set to `application/x-tar' ) ;
137
+ } ) ;
138
+ } ) ;
139
+
127
140
it ( 'allows `prefix` option to be passed to customize upload-path' , function ( ) {
128
141
var prefix = 'my-app' ;
129
142
You can’t perform that action at this time.
0 commit comments