Skip to main content

Files + Parts

Methods for accessing and managing access groups

ContentPart

ContentPart({
  libraryId, // optional
  objectId, // optional
  versionHash, // optional
  partHash
}) → Promise.<Object>

Get information on a specific part

Returns: Response containing information about the specified part

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

versionHashstring

Hash of the object version - if not specified, latest version will be used

partHashstring

Hash of the part to retrieve

ContentParts

ContentParts({
  libraryId, // optional
  objectId, // optional
  versionHash // optional
}) → Promise.<Object>

List content object parts

Returns: Response containing list of parts of the object

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

versionHashstring

Hash of the object version - if not specified, latest version will be used

CreateFileDirectories

CreateFileDirectories({
  libraryId,
  objectId,
  writeToken,
  filePaths
})

Create the specified directories on the specified object

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

filePathsArray.<string>

List of file paths to create

CreatePart

CreatePart({
  libraryId,
  objectId,
  writeToken,
  encryption // optional
}) → Promise.<string>

Create a part upload draft

Returns: The part write token for the part draft

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the content object draft

encryptionstring

Desired encryption scheme. Options: 'none' (default), 'cgck'

(default: none)

DeleteFiles

DeleteFiles({
  libraryId,
  objectId,
  writeToken,
  filePaths
})

Delete the specified list of files/directories

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

filePathsArray.<string>

List of file paths to delete

DeletePart

DeletePart({
  libraryId,
  objectId,
  writeToken,
  partHash
})

Delete the specified part from a content draft

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the content object draft

partHashstring

Hash of the part to delete

DownloadFile

DownloadFile({
  libraryId, // optional
  objectId, // optional
  versionHash, // optional
  writeToken, // optional
  filePath,
  format, // optional
  chunked, // optional
  chunkSize, // optional
  clientSideDecryption, // optional
  callback // optional
}) → Promise.<ArrayBuffer> | undefined

Download a file from a content object

Returns: No return if chunked is specified, file data in the requested format otherwise

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

versionHashstring

Hash of the object version - if not specified, latest version will be used

writeTokenstring

Write token for the draft from which to download the file

filePathstring

Path to the file to download

formatstring

Format in which to return the data ("blob" | "arraybuffer" | "buffer")

(default: "arrayBuffer")
chunkedboolean

If specified, file will be downloaded and decrypted in chunks. The specified callback will be invoked on completion of each chunk. This is recommended for large files.

(default: false)
chunkSizenumber

Size of file chunks to request for download

  • NOTE: If the file is encrypted, the size of the chunks returned via the callback function will not be affected by this value
(default: 1000000)
clientSideDecryptionboolean

If specified, decryption of the file (if necessary) will be done by the client instead of on the fabric node

(default: false)
callbackfunction

If specified, will be periodically called with current download status - Required if chunked is true

  • Signature: ({bytesFinished, bytesTotal}) => {}
  • Signature (chunked): ({bytesFinished, bytesTotal, chunk}) => {}

DownloadPart

DownloadPart({
  libraryId, // optional
  objectId, // optional
  versionHash, // optional
  writeToken, // optional
  partHash,
  format, // optional
  chunked, // optional
  chunkSize, // optional
  callback // optional
}) → Promise.<ArrayBuffer> | undefined

Download a part from a content object. The fromByte and range parameters can be used to specify a specific section of the part to download.

Returns: No return if chunked is specified, part data in the requested format otherwise

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

versionHashstring

Hash of the object version - if not specified, latest version will be used

writeTokenstring

Write token for the draft from which to download the part

partHashstring

Hash of the part to download

formatstring

Format in which to return the data ("blob" | "arraybuffer" | "buffer)

(default: "arrayBuffer")
chunkedboolean

If specified, part will be downloaded and decrypted in chunks. The specified callback will be invoked on completion of each chunk. This is recommended for large files, especially if they are encrypted.

(default: false)
chunkSizenumber

Size of file chunks to request for download

  • NOTE: If the file is encrypted, the size of the chunks returned via the callback function will not be affected by this value
(default: 1000000)
callbackfunction

If specified, will be periodically called with current download status - Required if chunked is true

  • Signature: ({bytesFinished, bytesTotal}) => {}
  • Signature (chunked): ({bytesFinished, bytesTotal, chunk}) => {}

FinalizePart

FinalizePart({
  libraryId,
  objectId,
  writeToken,
  partWriteToken,
  encryption // optional
}) → Promise.<object>

Finalize an open part draft

Returns: The finalize response for the new part

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the content object draft

partWriteTokenstring

Write token of the part

encryptionstring

Desired encryption scheme. Options: 'none' (default), 'cgck'

(default: none)

ListFiles

ListFiles({
  libraryId, // optional
  objectId, // optional
  path, // optional
  versionHash, // optional
  writeToken // optional
})

List the file information about this object

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

pathstring

ID of the object

versionHashstring

Hash of the object version - if not specified, most recent version will be used

writeTokenstring

Write token of a draft (incompatible with versionHash)

MoveFiles

MoveFiles({
  libraryId,
  objectId,
  writeToken,
  filePaths
})

Move or rename the specified list of files/directories

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

filePathsArray.<string>

List of file paths to move. Format: [ { "path": "original/path", to: "new/path" } ]

UploadFiles

UploadFiles({
  libraryId,
  objectId,
  writeToken,
  fileInfo,
  encryption,
  callback // optional
})

Upload files to a content object.

Expected format of fileInfo:

[
{
path: string,
mime_type: string,
size: number,
data: File | ArrayBuffer | Buffer | File Descriptor (Node)
}
]

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

fileInfoArray.<object>

List of files to upload, including their size, type, and contents

encryptionstring

Encryption for uploaded files - cgck | none

(default: "none")
callbackfunction

If specified, will be called after each job segment is finished with the current upload progress

  • Format: {"filename1": {uploaded: number, total: number}, ...}

UploadFilesFromS3

UploadFilesFromS3({
  libraryId,
  objectId,
  writeToken,
  region,
  bucket,
  fileInfo,
  accessKey,
  secret,
  signedUrl, // optional
  encryption,
  copy,
  callback // optional
})

Copy/reference files from S3 to a content object.

S3 authentication is done by either providing an access key and secret or a presigned URL. The credentials will not be stored (neither in the client nor in the Fabric)

NOTE: When providing a presigned URL instead of an access key + secret, the accessKey, secret, region and bucket parameters are not required.

Expected format of fileInfo:

[
{
path: string,
source: string // either a full path e.g. "s3://BUCKET_NAME/path..." or just the path part without "s3://BUCKET_NAME/"
}
]

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the draft

regionstring

AWS region to use

bucketstring

AWS bucket to use

fileInfoArray.<Object>

List of files to reference/copy

accessKeystring

AWS access key

secretstring

AWS secret

signedUrlstring
encryptionstring

Encryption for uploaded files (copy only) - cgck | none

(default: "none")
copyboolean

If true, will copy the data from S3 into the fabric. Otherwise, a reference to the content will be made.

(default: false)
callbackfunction

If specified, will be periodically called with current upload status

  • Arguments (copy): { done: boolean, uploaded: number, total: number, uploadedFiles: number, totalFiles: number, fileStatus: Object }
  • Arguments (reference): { done: boolean, uploadedFiles: number, totalFiles: number }

UploadPart

UploadPart({
  libraryId,
  objectId,
  writeToken,
  data,
  chunkSize, // optional
  encryption, // optional
  callback // optional
}) → Promise.<Object>

Upload part to an object draft

Note: If uploading a large file (especially with an HTML file and/or when using the FrameClient) it is recommended to use the CreatePart + UploadPartChunk + FinalizePart flow to upload the file in smaller chunks.

Returns: Response containing information about the uploaded part

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the content object draft

dataFile | ArrayBuffer | Buffer

Data to upload

chunkSizenumber

(1MB) - Chunk size, in bytes

(default: 1000000)
encryptionstring

Desired encryption scheme. Options: 'none' (default), 'cgck'

(default: none)
callbackfunction

If specified, will be periodically called with current upload status

  • Signature: ({bytesFinished, bytesTotal}) => {}

UploadPartChunk

UploadPartChunk({
  libraryId,
  objectId,
  writeToken,
  partWriteToken,
  chunk,
  encryption // optional
}) → Promise.<string>

Upload data to an open part draft

Returns: The part write token for the part draft

Parameters

NameTypeRequiredDescription
libraryIdstring

ID of the library

objectIdstring

ID of the object

writeTokenstring

Write token of the content object draft

partWriteTokenstring

Write token of the part

chunkArrayBuffer | Buffer

Data to upload

encryptionstring

Desired encryption scheme. Options: 'none' (default), 'cgck'

(default: none)