Skip to content

Commit 658495c

Browse files
author
jenweber
committed
account for changes to lookup/getType returning null #105
1 parent 052f7f1 commit 658495c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/s3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ module.exports = CoreObject.extend({
120120
var expires = options.expires;
121121
var serverSideEncryption = options.serverSideEncryption;
122122

123-
mime.default_type = options.defaultMimeType || mime.getType('bin');
123+
var defaultType = options.defaultMimeType || mime.getType('bin');
124124

125125
var basePath = path.join(cwd, filePath);
126126
var data = fs.readFileSync(basePath);
127-
var contentType = mime.getType(basePath);
127+
var contentType = mime.getType(basePath) || defaultType;
128128
var encoding = this._mimeCharsetsLookup(contentType);
129129
var key = prefix === '' ? filePath : [prefix, filePath].join('/');
130130
var isGzipped = gzippedFilePaths.indexOf(filePath) !== -1;
@@ -133,14 +133,14 @@ module.exports = CoreObject.extend({
133133
if (isGzipped && path.extname(basePath) === '.gz') {
134134
var basePathUngzipped = path.basename(basePath, '.gz');
135135
if (filePaths && filePaths.indexOf(basePathUngzipped) !== -1) {
136-
contentType = mime.getType(basePathUngzipped);
136+
contentType = mime.getType(basePathUngzipped) || defaultType;
137137
encoding = this._mimeCharsetsLookup(contentType);
138138
}
139139
}
140140
if (isBrotliCompressed) {
141141
var basePathUncompressed = path.basename(basePath, '.br');
142142
if (filePaths && filePaths.indexOf(basePathUncompressed) !== -1) {
143-
contentType = mime.getType(basePathUncompressed);
143+
contentType = mime.getType(basePathUncompressed) || defaultType;
144144
encoding = this._mimeCharsetsLookup(contentType);
145145
}
146146
}

0 commit comments

Comments
 (0)