feat: added basic S3 structure kind of

pull/243/head
Josh Moore 1 year ago
parent 0d01fb670b
commit f6b9aba0b8

@ -1,14 +1,45 @@
import { ReadStream } from 'fs';
import { UserConfig } from './UserConfig';
import { log } from './log';
import { AssFile } from 'ass';
const NYI = 'Not yet implemented';
const NYR = 'S3 not ready';
const s3readyCheck = (): boolean => UserConfig.ready && UserConfig.config.s3 != null;
/**
* Uploads a file to your configured S3 provider
*/
export const uploadFileS3 = () => { }
export const uploadFileS3 = (file: ReadStream, metadata: AssFile): Promise<string> => new Promise((resolve, reject) => {
if (!s3readyCheck) return reject(NYR);
// todo: S3 upload logic
metadata.filename;
metadata.mimetype;
metadata.sha256;
log.warn('S3 Upload', NYI);
reject(NYI);
});
/**
* Gets a file from your configured S3 provider
*/
export const getFileS3 = () => { }
export const getFileS3 = (): Promise<string> => new Promise((resolve, reject) => {
if (!s3readyCheck) return reject(NYR);
// todo: S3 get logic
log.warn('S3 Get', NYI);
reject(NYI);
});
/**
* Deletes a file from your configured S3 provider
*/
export const deleteFileS3 = () => { }
export const deleteFileS3 = (): Promise<void> => new Promise((resolve, reject) => {
if (!s3readyCheck) return reject(NYR);
log.warn('S3 Delete', NYI);
reject(NYI);
});

30
common/types.d.ts vendored

@ -19,6 +19,30 @@ declare module 'ass' {
idSize: number;
gfySize: number;
maximumFileSize: number;
s3?: S3Configuration;
}
interface S3Configuration {
/**
* S3 endpoint to use
*/
endpoint: string;
/**
* Bucket to upload to
*/
bucket: string;
/**
* Optional region. Required for some providers
*/
region?: string;
/**
* Access credentials
*/
credentials: {
accessKey: string;
secretKey: string;
}
}
interface UserConfigTypeChecker {
@ -47,7 +71,11 @@ declare module 'ass' {
filename: string;
save: {
local?: string;
s3?: any;
s3?: {
privateUrl?: string;
publicUrl?: string;
thumbnailUrl?: string;
}
}
sha256: string;
timestamp: string;

Loading…
Cancel
Save