Home Reference Source
import {FileBrowserFolderFile} from '@fnndsc/chrisapi'
public class | source

FileBrowserFolderFile

Extends:

ResourceItemResource → FileBrowserFolderFile

File browser folder file item resource object representing a generic browser file.

Method Summary

Public Methods
public

addGroupPermission(group_name: string, permission: string, timeout: number): Promise<FileGroupPermission>

Add a group permission to access the file.

public

addUserPermission(username: string, permission: string, timeout: number): Promise<FileUserPermission>

Add a user permission to access the file.

public

delete(timeout: number): Promise

Make a DELETE request to delete this file item resource through the REST API.

public

getFileBlob(timeout: number): Promise<Blob>

Fetch the file blob associated to this file item from the REST API.

public

Get a file group permission given the name of the group.

public

Fetch a list of group permissions associated to this file from the REST API.

public

Fetch the parent folder of this file from the REST API.

public

Get a file user permission given the username of the user.

public

Fetch a list of user permissions associated to this file from the REST API.

public

makePublic(timeout: number): Promise<this>

Make the file public.

public

makeUnpublic(timeout: number): Promise<this>

Make the file unpublic.

public

put(data: Object, timeout: number): Promise<this>

Make a PUT request to modify this file item resource through the REST API.

Inherited Summary

From class Resource
public static

cloneObj(obj: Object): *

Helper method to make a deep copy clone of the passed object resource.

public get

Return true if the resource object contains any data.

public
public
public
public
public

Make a deep copy clone of this object resource.

From class ItemResource
public get

Get the item's data object (REST API descriptors).

public
public

get(timeout: number): Promise<this>

Fetch this item resource from the REST API.

public

Get an array of parameter names that can be used as properties of the data object in PUT requests.

private

_delete(timeout: number): Promise

Internal helper method to make a DELETE request to this item resource through the REST API.

private

_getResource(linkRelation: string, ResourceClass: Object, searchParams: Object, timeout: number): Promise<ResourceClass>

Internal method to fetch a related resource from the REST API that is referenced by a link relation within the item object.

private

_put(data: Object, uploadFileObj: Object, timeout: number): Promise<this>

Internal helper method to make a PUT request to this item resource through the REST API.

Public Methods

public addGroupPermission(group_name: string, permission: string, timeout: number): Promise<FileGroupPermission> source

Add a group permission to access the file.

Params:

NameTypeAttributeDescription
group_name string

group's name

permission string

permission, can be 'r' or 'w'

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileGroupPermission>

JS Promise, resolves to a FileGroupPermission object

public addUserPermission(username: string, permission: string, timeout: number): Promise<FileUserPermission> source

Add a user permission to access the file.

Params:

NameTypeAttributeDescription
username string

user's username

permission string

permission, can be 'r' or 'w'

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileUserPermission>

JS Promise, resolves to a FileUserPermission object

public delete(timeout: number): Promise source

Make a DELETE request to delete this file item resource through the REST API.

Params:

NameTypeAttributeDescription
timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise

JS Promise

public getFileBlob(timeout: number): Promise<Blob> source

Fetch the file blob associated to this file item from the REST API.

Params:

NameTypeAttributeDescription
timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<Blob>

JS Promise, resolves to a Blob object

public getGroupPermission(group_name: string, timeout: number): Promise<FileGroupPermission|null> source

Get a file group permission given the name of the group.

Params:

NameTypeAttributeDescription
group_name string

file group permission's group name

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileGroupPermission|null>

JS Promise, resolves to a FileGroupPermission object or null

public getGroupPermissions(searchParams: Object, timeout: number): Promise<FileGroupPermissionList> source

Fetch a list of group permissions associated to this file from the REST API.

Params:

NameTypeAttributeDescription
searchParams Object
  • optional
  • default: null

search parameters object

searchParams.limit number
  • optional

page limit

searchParams.offset number
  • optional

page offset

searchParams.id number
  • optional

match file group permission id exactly with this number

searchParams.group_name string
  • optional

match group name exactly with this string

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileGroupPermissionList>

JS Promise, resolves to a FileGroupPermissionList object

public getParentFolder(timeout: number): Promise<FileBrowserFolder> source

Fetch the parent folder of this file from the REST API.

Params:

NameTypeAttributeDescription
timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileBrowserFolder>

JS Promise, resolves to a FileBrowserFolder object

public getUserPermission(username: string, timeout: number): Promise<FileUserPermission|null> source

Get a file user permission given the username of the user.

Params:

NameTypeAttributeDescription
username string

file user permission's username

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileUserPermission|null>

JS Promise, resolves to a FileUserPermission object or null

public getUserPermissions(searchParams: Object, timeout: number): Promise<FileUserPermissionList> source

Fetch a list of user permissions associated to this file from the REST API.

Params:

NameTypeAttributeDescription
searchParams Object
  • optional
  • default: null

search parameters object

searchParams.limit number
  • optional

page limit

searchParams.offset number
  • optional

page offset

searchParams.id number
  • optional

match file user permission id exactly with this number

searchParams.username string
  • optional

match username exactly with this string

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<FileUserPermissionList>

JS Promise, resolves to a FileUserPermissionList object

public makePublic(timeout: number): Promise<this> source

Make the file public.

Params:

NameTypeAttributeDescription
timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<this>

JS Promise, resolves to this object

public makeUnpublic(timeout: number): Promise<this> source

Make the file unpublic.

Params:

NameTypeAttributeDescription
timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<this>

JS Promise, resolves to this object

public put(data: Object, timeout: number): Promise<this> source

Make a PUT request to modify this file item resource through the REST API.

Params:

NameTypeAttributeDescription
data Object

request JSON data object

data.public boolean
  • optional

public status of the file

data.new_file_path string
  • optional

absolute path including file name where the file will be uploaded on the storage service

timeout number
  • optional
  • default: 30000

request timeout

Return:

Promise<this>

JS Promise, resolves to this object