refile-js
Install
npm install --save @blackglory/refile-js
# or
yarn add @blackglory/refile-js
API
getFileHash
getFileHash(file: Blob | string): Promise<string>
RefileClient
new RefileClient({
server: string
, token?: string
, basicAuth?: {
username: string
, password: string
}
, keepalive?: boolean
, timeout?: number
})
interface IRefileClientRequestOptions {
signal?: AbortSignal
token?: string
keepalive?: boolean
timeout?: number | false
}
interface IRefileClientRequestOptionsWithoutToken {
signal?: AbortSignal
keepalive?: boolean
timeout?: number | false
}
uploadFile
RefileClient#uploadFile(file: Blob | string, options?: IRefileClientRequestOptionsWithoutToken): Promise<void>
getFileInfo
RefileClient#getFileInfo(hash: string, options?: IRefileClientRequestOptions): Promise<{
hash: string
location: string | null
references: number
}>
getFileLocation
RefileClient#getFileLocation(
hash: string
, options?: IRefileClientRequestOptions
): Promise<string | undefined>
setReference
RefileClient#setReference(
namespace: string
, id: string
, fileHash: string
, options?: IRefileClientRequestOptions
): Promise<void>
removeReference
RefileClient#removeReference(
namespace: string
, id: string
, fileHash: string
, options?: IRefileClientRequestOptions
): Promise<void>
removeReferencesByItem
RefileClient#removeReferencesByItem(
namespace: string
, id: string
, options?: IRefileClientRequestOptions
): Promise<void>
removeReferencesByNamespace
RefileClient#removeReferencesByNamespace(
namespace: string
, options?: IRefileClientRequestOptions
): Promise<void>
getAllNamespaces
RefileClient#getAllNamespaces(
options?: IRefileClientRequestOptionsWithoutToken
): Promise<string[]>
getAllItemIds
RefileClient#getAllItemIds(
namespace: string
, options?: IRefileClientRequestOptions
): Promise<string[]>
getFileHashesByItem
RefileClient#getFileHashesByItem(
namespace: string
, id: string
, options?: IRefileClientRequestOptions
): Promise<string[]>
getItemIdsByFile
RefileClient#getItemIdsByFile(
fileHash: string
, namespace: string
, options?: IRefileClientRequestOptions
): Promise<string[]>
collectGarbage
RefileClient#collectGarbage(options?: IRefileClientRequestOptionsWithoutToken): Promise<void>
RefileManager
new RefileManager({
server: string
, adminPassword: string
, keepalive?: boolean
, timeout?: number
})
interface IRefileManagerRequestOptions {
signal?: AbortSignal
keepalive?: boolean
timeout?: number | false
}
Blacklist
getNamespaces
RefileManager#Blacklist.getNamespaces(
options?: IRefileManagerRequestOptions
): Promise<string[]>
add
RefileManager#Blacklist.add(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
remove
RefileManager#Blacklist.remove(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
Whitelist
getNamespaces
RefileManager#Whitelist.getNamespaces(
options?: IRefileManagerRequestOptions
): Promise<string[]>
add
RefileManager#Whitelist.add(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
remove
RefileManager#Whitelist.remove(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
TokenPolicy
getNamespaces
RefileManager#TokenPolicy.getNamespaces(
options?: IRefileManagerRequestOptions
): Promise<string[]>
get
RefileManager#TokenPolicy.get(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<{
writeTokenRequired: boolean | null
readTokenRequired: boolean | null
deleteTokenRequired: boolean | null
}>
setWriteTokenRequired
RefileManager#TokenPolicy.setWriteTokenRequired(
namespace: string
, val: boolean
, options?: IRefileManagerRequestOptions
): Promise<void>
removeWriteTokenRequired
RefileManager#TokenPolicy.removeWriteTokenRequired(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
setReadTokenRequired
RefileManager#TokenPolicy.setReadTokenRequired(
namespace: string
, val: boolean
, options?: IRefileManagerRequestOptions
): Promise<void>
removeReadTokenRequired
RefileManager#TokenPolicy.removeReadTokenRequired(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
setDeleteTokenRequired
RefileManager#TokenPolicy.setDeleteTokenRequired(
namespace: string
, val: boolean
, options?: IRefileManagerRequestOptions
): Promise<void>
removeDeleteTokenRequired
RefileManager#TokenPolicy.removeDeleteTokenRequired(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<void>
Token
getNamespaces
RefileManager#Token.getNamespaces(options?: IRefileManagerRequestOptions): Promise<string[]>
getTokens
RefileManager#Token.getTokens(
namespace: string
, options?: IRefileManagerRequestOptions
): Promise<Array<{
token: string
write: boolean
read: boolean
delete: boolean
}>>
addWriteToken
RefileManager#Token.addWriteToken(
namespace: string
, token: string
, options?: IRefileManagerRequestOptions
): Promise<void>
removeWriteToken
RefileManager#Token.removeWriteToken(
namespace: string
, token: string
, options?: IRefileManagerRequestOptions
): Promise<void>
addReadToken
RefileManager#Token.addReadToken(
namespace: string
, token: string
, options?: IRefileManagerRequestOptions
): Promise<void>
removeReadToken
RefileManager#Token.removeReadToken(
namespace: string
, token: string
, options?: IRefileManagerRequestOptions
): Promise<void>
addDeleteToken
RefileManager#Token.addDeleteToken(
namespace: string
, token: string
, options?: IRefileManagerRequestOptions
): Promise<void>
removeDeleteToken
RefileManager#Token.removeDeleteToken(
namespace: string
, token: string
, options?: IRefileManagerRequestOptions
): Promise<void>