Browse Source

Merge pull request #4408 from openmind-sw/s3-add-content-type

Add content-type to S3-compatible storages
pull/4418/head
Pranav C 2 years ago committed by GitHub
parent
commit
11faf366a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts
  2. 6
      packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts
  3. 6
      packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts
  4. 6
      packages/nocodb/src/lib/plugins/s3/S3.ts
  5. 6
      packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts
  6. 6
      packages/nocodb/src/lib/plugins/spaces/Spaces.ts
  7. 6
      packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts
  8. 6
      packages/nocodb/src/lib/plugins/vultr/Vultr.ts

6
packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts

@ -18,6 +18,7 @@ export default class Backblaze implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class Backblaze implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -126,7 +128,7 @@ export default class Backblaze implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

6
packages/nocodb/src/lib/plugins/linode/LinodeObjectStorage.ts

@ -18,6 +18,7 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -116,7 +118,7 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

6
packages/nocodb/src/lib/plugins/ovhCloud/OvhCloud.ts

@ -18,6 +18,7 @@ export default class OvhCloud implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class OvhCloud implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -116,7 +118,7 @@ export default class OvhCloud implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

6
packages/nocodb/src/lib/plugins/s3/S3.ts

@ -18,6 +18,7 @@ export default class S3 implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -53,11 +54,12 @@ export default class S3 implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -119,7 +121,7 @@ export default class S3 implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

6
packages/nocodb/src/lib/plugins/scaleway/ScalewayObjectStorage.ts

@ -36,7 +36,7 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});
@ -68,6 +68,7 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -104,11 +105,12 @@ export default class ScalewayObjectStorage implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {

6
packages/nocodb/src/lib/plugins/spaces/Spaces.ts

@ -18,6 +18,7 @@ export default class Spaces implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class Spaces implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -124,7 +126,7 @@ export default class Spaces implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

6
packages/nocodb/src/lib/plugins/upcloud/UpoCloud.ts

@ -18,6 +18,7 @@ export default class UpoCloud implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class UpoCloud implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -114,7 +116,7 @@ export default class UpoCloud implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

6
packages/nocodb/src/lib/plugins/vultr/Vultr.ts

@ -18,6 +18,7 @@ export default class Vultr implements IStorageAdapterV2 {
async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = {
ACL: 'public-read',
ContentType: file.mimetype,
};
return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class Vultr implements IStorageAdapterV2 {
url: url,
encoding: null,
},
(err, _, body) => {
(err, httpResponse, body) => {
if (err) return reject(err);
uploadParams.Body = body;
uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => {
@ -116,7 +118,7 @@ export default class Vultr implements IStorageAdapterV2 {
await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', {
path: tempFile,
mimetype: '',
mimetype: 'text/plain',
originalname: 'temp.txt',
size: '',
});

Loading…
Cancel
Save