Browse Source

Add content-type to S3-compatible storages

pull/4408/head
Simon Bergmann 2 years ago
parent
commit
35b7bbc383
  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> { async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = { const uploadParams: any = {
ACL: 'public-read', ACL: 'public-read',
ContentType: file.mimetype,
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters // Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class Backblaze implements IStorageAdapterV2 {
url: url, url: url,
encoding: null, encoding: null,
}, },
(err, _, body) => { (err, httpResponse, body) => {
if (err) return reject(err); if (err) return reject(err);
uploadParams.Body = body; uploadParams.Body = body;
uploadParams.Key = key; uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket // call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => { this.s3Client.upload(uploadParams, (err1, data) => {
@ -126,7 +128,7 @@ export default class Backblaze implements IStorageAdapterV2 {
await waitForStreamClose(createStream); await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', { await this.fileCreate('nc-test-file.txt', {
path: tempFile, path: tempFile,
mimetype: '', mimetype: 'text/plain',
originalname: 'temp.txt', originalname: 'temp.txt',
size: '', 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> { async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = { const uploadParams: any = {
ACL: 'public-read', ACL: 'public-read',
ContentType: file.mimetype,
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters // Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 {
url: url, url: url,
encoding: null, encoding: null,
}, },
(err, _, body) => { (err, httpResponse, body) => {
if (err) return reject(err); if (err) return reject(err);
uploadParams.Body = body; uploadParams.Body = body;
uploadParams.Key = key; uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket // call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => { this.s3Client.upload(uploadParams, (err1, data) => {
@ -116,7 +118,7 @@ export default class LinodeObjectStorage implements IStorageAdapterV2 {
await waitForStreamClose(createStream); await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', { await this.fileCreate('nc-test-file.txt', {
path: tempFile, path: tempFile,
mimetype: '', mimetype: 'text/plain',
originalname: 'temp.txt', originalname: 'temp.txt',
size: '', 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> { async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = { const uploadParams: any = {
ACL: 'public-read', ACL: 'public-read',
ContentType: file.mimetype,
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters // Configure the file stream and obtain the upload parameters
@ -54,11 +55,12 @@ export default class OvhCloud implements IStorageAdapterV2 {
url: url, url: url,
encoding: null, encoding: null,
}, },
(err, _, body) => { (err, httpResponse, body) => {
if (err) return reject(err); if (err) return reject(err);
uploadParams.Body = body; uploadParams.Body = body;
uploadParams.Key = key; uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket // call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => { this.s3Client.upload(uploadParams, (err1, data) => {
@ -116,7 +118,7 @@ export default class OvhCloud implements IStorageAdapterV2 {
await waitForStreamClose(createStream); await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', { await this.fileCreate('nc-test-file.txt', {
path: tempFile, path: tempFile,
mimetype: '', mimetype: 'text/plain',
originalname: 'temp.txt', originalname: 'temp.txt',
size: '', 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> { async fileCreate(key: string, file: XcFile): Promise<any> {
const uploadParams: any = { const uploadParams: any = {
ACL: 'public-read', ACL: 'public-read',
ContentType: file.mimetype,
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Configure the file stream and obtain the upload parameters // Configure the file stream and obtain the upload parameters
@ -53,11 +54,12 @@ export default class S3 implements IStorageAdapterV2 {
url: url, url: url,
encoding: null, encoding: null,
}, },
(err, _, body) => { (err, httpResponse, body) => {
if (err) return reject(err); if (err) return reject(err);
uploadParams.Body = body; uploadParams.Body = body;
uploadParams.Key = key; uploadParams.Key = key;
uploadParams.ContentType = httpResponse.headers['content-type'];
// call S3 to retrieve upload file to specified bucket // call S3 to retrieve upload file to specified bucket
this.s3Client.upload(uploadParams, (err1, data) => { this.s3Client.upload(uploadParams, (err1, data) => {
@ -119,7 +121,7 @@ export default class S3 implements IStorageAdapterV2 {
await waitForStreamClose(createStream); await waitForStreamClose(createStream);
await this.fileCreate('nc-test-file.txt', { await this.fileCreate('nc-test-file.txt', {
path: tempFile, path: tempFile,
mimetype: '', mimetype: 'text/plain',
originalname: 'temp.txt', originalname: 'temp.txt',
size: '', size: '',
}); });

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

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

Loading…
Cancel
Save