mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-23 22:47:28 +00:00
* started working on node upgrade to 18.18.2 * testing ci * updated ci node version * updated action code * deleted all package-lock.json files * deleted and ovverrided some packages * deleted and fixed server & frontend vulnerabilities * updated firestore version * fix: ws type issue * fix: upgraded lerna version * regenerated package-lock.json files again * regenerated marketplace lock file * updated node version in other ci and docker files * update: lock file plugin side * updated the npm version in docker & ci files * removed unused imports from events file * removed dependency-review action * updated some packages * tried to go with current node-module of jest. had to upgrade * fix: deprecated function usage - ts-jest * fix: server directory lint issues * fixed login page issue after router-dom upgrade * updated import/no-unresolved rule to ignore import errors of react-loading-skeleton, react-spring packages * fix: cypress node version & package-lock issue * regenerated cli package-lock.json * fix: new webpack version might cause runtime issues (had issues with enterprise). lets use old version only * fix: form-data docker issue * removed comment
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
import { Client as MinioClient } from 'minio';
|
|
import { Stream } from 'stream';
|
|
|
|
export async function listBuckets(minioClient: MinioClient, _queryOptions: object): Promise<object> {
|
|
return await minioClient.listBuckets();
|
|
}
|
|
|
|
export async function listObjects(minioClient: MinioClient, queryOptions: object): Promise<object> {
|
|
const stream = minioClient.listObjectsV2(
|
|
queryOptions['bucket'],
|
|
queryOptions['prefix'],
|
|
true // recursive
|
|
);
|
|
const streamToData = (stream: Stream) =>
|
|
new Promise((resolve, reject) => {
|
|
const chunks = [];
|
|
stream.on('data', (chunk) => chunks.push(chunk));
|
|
stream.on('error', reject);
|
|
stream.on('end', () => resolve(chunks));
|
|
});
|
|
const bodyContents = await streamToData(stream);
|
|
|
|
return { Body: bodyContents };
|
|
}
|
|
|
|
export async function signedUrlForGet(minioClient: MinioClient, queryOptions: object): Promise<object> {
|
|
const defaultExpiry = +queryOptions['expiresIn'] || 86400;
|
|
const url = await minioClient.presignedGetObject(queryOptions['bucket'], queryOptions['objectName'], defaultExpiry);
|
|
|
|
return { url };
|
|
}
|
|
|
|
export async function getObject(minioClient: MinioClient, queryOptions: object): Promise<object> {
|
|
const stream = await minioClient.getObject(queryOptions['bucket'], queryOptions['objectName']);
|
|
const streamToString = (stream: Stream) =>
|
|
new Promise((resolve, reject) => {
|
|
const chunks = [];
|
|
stream.on('data', (chunk) => chunks.push(chunk));
|
|
stream.on('error', reject);
|
|
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
|
|
});
|
|
const bodyContents = await streamToString(stream);
|
|
|
|
return { Body: bodyContents };
|
|
}
|
|
|
|
export async function uploadObject(minioClient: MinioClient, queryOptions: object): Promise<object> {
|
|
return await minioClient.putObject(
|
|
queryOptions['bucket'],
|
|
queryOptions['objectName'],
|
|
queryOptions['data'],
|
|
queryOptions['contentType'] && { contentType: queryOptions['contentType'] }
|
|
);
|
|
}
|
|
|
|
export async function signedUrlForPut(minioClient: MinioClient, queryOptions: object): Promise<object> {
|
|
const defaultExpiry = +queryOptions['expiresIn'] || 86400;
|
|
const url = await minioClient.presignedPutObject(queryOptions['bucket'], queryOptions['objectName'], defaultExpiry);
|
|
|
|
return { url };
|
|
}
|
|
|
|
export async function removeObject(minioClient: MinioClient, queryOptions: object): Promise<object> {
|
|
await minioClient.removeObject(queryOptions['bucket'], queryOptions['objectName']);
|
|
return {};
|
|
}
|