docs: added description
This commit is contained in:
parent
6bf28d11a8
commit
6718b4a10b
1 changed files with 20 additions and 0 deletions
|
|
@ -3,11 +3,26 @@ import minioClient from "../storage";
|
|||
|
||||
/**
|
||||
* Remove slash at the start and ensure slash at the end of the path
|
||||
* @param path - path to be check and ensure
|
||||
* @returns path without / at start and end with trailing slash
|
||||
*/
|
||||
function safePath(path: string) {
|
||||
return path.replace(/^\/|\/$/g, "") + "/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace illegal character eg. ? % < > / \ : | that can't be in path with "-".
|
||||
* @param path - string to check and replace
|
||||
* @returns path with illegal character replaced with "-"
|
||||
*/
|
||||
export function replaceIllegalChars(path: string, replaceChar = "-") {
|
||||
return path.replace(/[/\\?%*:|"<>]/g, "-");
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to check for .keep file if it is exist or not.
|
||||
* @returns true if .keep exist, false otherwise
|
||||
*/
|
||||
export async function pathExist(path: string): Promise<boolean> {
|
||||
return await minioClient
|
||||
.statObject("ehr", `${safePath(path)}.keep`)
|
||||
|
|
@ -18,6 +33,11 @@ export async function pathExist(path: string): Promise<boolean> {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to list folder by using .keep file with prefix in minio.
|
||||
* @param path - path to list
|
||||
* @return list of folder with metadata
|
||||
*/
|
||||
export function listFolder(path?: string): Promise<EhrFolder[]> {
|
||||
if (path) path = safePath(path);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue