Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from Financial-Times/hashed-assets-rename
Browse files Browse the repository at this point in the history
Specify ContentType for hashed assets - hopefully fixes #47
  • Loading branch information
matthew-andrews committed Apr 7, 2015
2 parents 064d052 + 8a5d142 commit 333def1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tasks/deploy-hashed-assets-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function hashAndUpload(opts) {
var app = opts.app;
var bucket = 'ft-next-hashed-assets-prod';
var key = 'hashed-assets/' + app + '/' + file.hashedName;
var extension = (/\.([^.]+)$/.exec(file.name) || [undefined, undefined])[1];

return new Promise(function(resolve, reject) {
var s3bucket = new aws.S3({ params: { Bucket: bucket } });
Expand All @@ -33,6 +34,14 @@ function hashAndUpload(opts) {
// @arjun, did you think this was in milliseconds? It's fine to set a cache header of 19.165 years but seems like an odd choice
CacheControl: 'public, max-age=604800000'
};
switch(extension) {
case 'js':
params.ContentType = 'text/javascript';
break;
case 'css':
params.ContentType = 'text/css';
break;
}
s3bucket.upload(params, function(err, data) {
if (err) {
console.log("Error uploading data: ", err);
Expand Down

0 comments on commit 333def1

Please sign in to comment.