1.0.2 • Published 3 years ago
@rugo-vn/storage v1.0.2
Rugo Storage
File management for Rugo Platform.
Concepts
Every space have many items to store file, along with table, called drive.
Settings
const settings = {
storage: /* root directory to store a file, should absolute path */,
}Commons
Input Args
As same as table, drive should have spaceId and driveName as required args. But, we do not define schema for drive.
Items
Each item in drive can be file or dir (folder) (called entry). But they have same infomation.
path: Location ofentry, related withdriveName. Always beginning with slash/character.name: Name ofentry.mime: Mime ofentry, parsed frompath.inode/directoryif directory.parent: Parent path ofentry, parsed frompath. Always beginning with slash/character.isDir: Is directory or not.size: File size,0if directory.data:FileCursorto file,nullif directory.updatedAt:ctimeofentry.
Actions
setConfig
Arguments:
config
Return:
- (type:
object) config object.
getConfig
Return:
- (type:
object) config object.
create
Arguments:
path(type:string) path that you need to create entry.isDir(type:boolean)trueif you need to create a directory. Defaultfalse.data(type:FileCursor) data to create a file. Default it will create an empty file.
list
Arguments:
path(type:string) path of directory to list.
Return:
- (type:
array) result entries.
get
Arguments:
path(type:string) path of entry to get info.
Return:
- (type:
object) entry object.
remove
Arguments:
path(type:string) path of remove file.
Return:
- (type:
object) entry object.
move
Arguments:
from(type:string) src path to move.to(type:string) dest path move to, this is a new entry.
compress
Arguments:
from(type:string) path of entry to compress.to(type:string) dest path to put compress file, it will create a new file.
Return:
- (type:
object) entry object.
extract
Arguments:
from(type:string) path of entry to extract.to(type:string) dest path to put extract content, it will create a new directory.
Return:
- (type:
object) entry object.
License
MIT.