Adds content type support in S3

This commit is contained in:
Florent Vilmart
2016-03-01 09:02:33 -05:00
parent 9287afc3c2
commit 78d380df72
6 changed files with 22 additions and 13 deletions

View File

@@ -12,7 +12,7 @@
// database adapter.
export class FilesAdapter {
createFile(config, filename, data) { }
createFile(config, filename: string, data, contentType: string) { }
deleteFile(config, filename) { }

View File

@@ -28,7 +28,7 @@ export class GridStoreAdapter extends FilesAdapter {
// For a given config object, filename, and data, store a file
// Returns a promise
createFile(config, filename: string, data) {
createFile(config, filename: string, data, contentType: string) {
return this._connect().then(database => {
let gridStore = new GridStore(database, filename, 'w');
return gridStore.open();

View File

@@ -68,7 +68,7 @@ export class S3Adapter extends FilesAdapter {
// For a given config object, filename, and data, store a file in S3
// Returns a promise containing the S3 object creation response
createFile(config, filename, data) {
createFile(config, filename, data, contentType) {
let params = {
Key: this._bucketPrefix + filename,
Body: data
@@ -76,6 +76,9 @@ export class S3Adapter extends FilesAdapter {
if (this._directAccess) {
params.ACL = "public-read"
}
if (contentType) {
params.ContentType = contentType;
}
return this.createBucket().then(() => {
return new Promise((resolve, reject) => {
this._s3Client.upload(params, (err, data) => {