mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-03 20:45:24 +02:00
S3 uploads support (#273)
* finish s3 uploads implementation * remove unnecessary file * fix docs * update DEVELOPMENT.md * update doc * update default uploads path
This commit is contained in:
parent
55b4b3ee61
commit
8c794304b6
16 changed files with 1373 additions and 248 deletions
|
@ -17,9 +17,7 @@ export interface FileData {
|
|||
_id?: EntityId;
|
||||
name?: string;
|
||||
filename?: string;
|
||||
path?: string;
|
||||
mimetype?: string;
|
||||
url?: string;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
|
@ -37,10 +35,8 @@ class File {
|
|||
public _id?: EntityId;
|
||||
public name?: string;
|
||||
public filename?: string;
|
||||
public path?: string;
|
||||
public mimetype?: string;
|
||||
public size?: number;
|
||||
public url?: string;
|
||||
|
||||
/**
|
||||
* @class
|
||||
|
@ -99,14 +95,12 @@ class File {
|
|||
* @param {FileData} fileData - info about file
|
||||
*/
|
||||
public set data(fileData: FileData) {
|
||||
const { name, filename, path, mimetype, size, url } = fileData;
|
||||
const { name, filename, mimetype, size } = fileData;
|
||||
|
||||
this.name = name || this.name;
|
||||
this.filename = filename || this.filename;
|
||||
this.path = path ? this.processPath(path) : this.path;
|
||||
this.mimetype = mimetype || this.mimetype;
|
||||
this.size = size || this.size;
|
||||
this.url = url || this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,10 +113,8 @@ class File {
|
|||
_id: this._id,
|
||||
name: this.name,
|
||||
filename: this.filename,
|
||||
path: this.path,
|
||||
mimetype: this.mimetype,
|
||||
size: this.size,
|
||||
url: this.url,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -164,16 +156,6 @@ class File {
|
|||
public toJSON(): FileData {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes unnecessary public folder prefix
|
||||
*
|
||||
* @param {string} path - input path to be processed
|
||||
* @returns {string}
|
||||
*/
|
||||
private processPath(path: string): string {
|
||||
return path.replace(/^public/, '');
|
||||
}
|
||||
}
|
||||
|
||||
export default File;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue