Content Management
Methods for managing content types, libraries and objects
AddLibraryContentType
libraryId,
typeId, // optional
typeName, // optional
typeHash, // optional
customContractAddress // optional
}) → Promise.<string>
Add a specified content type to a library
Returns: Hash of the addContentType transaction
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
typeId | string | ID of the content type | |
typeName | string | Name of the content type | |
typeHash | string | Version hash of the content type | |
customContractAddress | string | Address of the custom contract to associate with this content type for this library |
CopyContentObject
libraryId,
originalVersionHash,
options // optional
}) → Promise.<Object>
Create a new content object draft from an existing content object version.
Note: The type of the new copy can be different from the original object.
Returns: Response containing the object ID and write token of the draft
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library in which to create the new object |
originalVersionHash | ✓ | Version hash of the object to copy | |
options | Object | type: Version hash of the content type to associate with the object - may be different from the original object meta: Metadata to use for the new object - This will be merged into the metadata of the original object |
CreateAndFinalizeContentObject
libraryId,
callback, // optional
options, // optional
commitMessage, // optional
publish, // optional
awaitCommitConfirmation // optional
}) → Promise.<object>
Create and finalize new content object draft from an existing object.
Equivalent to:
CreateContentObject()
callback({objectId, writeToken})
FinalizeContentObject()
Returns: Response from FinalizeContentObject
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
callback | function | Async function to perform after creating the content draft and before finalizing. Object ID and write token are passed as named parameters. | |
options | object | meta: New metadata for the object - will be merged into existing metadata if specified type: New type for the object - Object ID, version hash or name of type | |
commitMessage | string | Message to include about this commit | |
publish | boolean | If specified, the object will also be published (default:true) | |
awaitCommitConfirmation | boolean | If specified, will wait for the publish commit to be confirmed. Irrelevant if not publishing. (default:true) |
CreateContentLibrary
name,
description, // optional
image, // optional
imageName, // optional
metadata, // optional
kmsId, // optional
tenantContractId // optional
}) → Promise.<string>
Create a new content library.
A new content library contract is deployed from the content space, and that contract ID is used to determine the library ID to create in the fabric.
Returns: Library ID of created library
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | ✓ | Library name |
description | string | Library description | |
image | blob | Image associated with the library | |
imageName | string | Name of the image associated with the library (required if image specified) | |
metadata | Object | Metadata of library object | |
kmsId | string | ID of the KMS to use for content in this library. If not specified, the default KMS will be used. | |
tenantContractId | string | ID of the tenant to use for this library |
CreateContentObject
libraryId,
objectId, // optional
options // optional
}) → Promise.<Object>
Create a new content object draft.
A new content object contract is deployed from the content library, and that contract ID is used to determine the object ID to create in the fabric.
Returns: Response containing the object ID and write token of the draft, as well as the url of the node that created the write token.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ID of the object (if contract already exists) | |
options | Object | type: Version hash of the content type to associate with the object meta: Metadata to use for the new object noEncryptionConk: Set to true to prevent creation of an encryption conk for the object createKMSConk: Set to true to create a KMS conk for object (usually for sharing a playable object) (incompatible with noEncryptionConk: true) |
CreateContentType
libraryId, // optional
name,
metadata,
bitcode // optional
}) → Promise.<string>
Create a new content type.
A new content type contract is deployed from
the content space, and that contract ID is used to determine the object ID to
create in the fabric. The content type object will be created in the special
content space library (ilib
Returns: Object ID of created content type
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ID of the library in which to create the content type. If not specified, it will be created in the content space library | |
name | string | ✓ | Name of the content type |
metadata | object | ✓ | Metadata for the new content type |
bitcode | Blob | Buffer | Bitcode to be used for the content type |
CreateLinks
libraryId,
objectId,
writeToken,
links
})
Create links to files, metadata and/or representations of this or or other content objects.
Expected format of links:
[ { path: string (metadata path for the link) target: string (path to link target), type: string ("file", "meta" | "metadata", "rep" - default "metadata") targetHash: string (optional, for cross-object links), autoUpdate: boolean (if specified, link will be automatically updated to latest version by UpdateContentObjectGraph method), authContainer: string (optional, object id of container object if creating a signed link) } ]
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
links | Array.<Object> | ✓ | Link specifications |
CreateNonOwnerCap
libraryId,
objectId,
publicKey,
writeToken
}) → Promise.<Object>
Create a non-owner cap key using the specified public key and address
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
publicKey | string | ✓ | Public key for the target cap |
writeToken | string | ✓ | Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing |
DeleteContentLibrary
NOT YET SUPPORTED - Delete the specified content library
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library to delete |
DeleteContentObject
libraryId,
objectId
})
Delete specified content object
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
DeleteContentVersion
Delete specified version of the content object
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
versionHash | string | Hash of the object version - if not specified, most recent version will be deleted |
DeleteMetadata
libraryId,
objectId,
writeToken,
metadataSubtree // optional
})
Delete content object metadata of specified subtree
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
metadataSubtree | string | Subtree of the object metadata to modify
|
DeleteWriteToken
Delete the specified write token
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
writeToken | string | ✓ | Write token to delete |
EditAndFinalizeContentObject
libraryId,
objectId,
callback, // optional
options, // optional
commitMessage, // optional
publish, // optional
awaitCommitConfirmation // optional
}) → Promise.<object>
Create and finalize new content object draft from an existing object.
Equivalent to:
EditContentObject()
callback({writeToken})
FinalizeContentObject()
Returns: Response from FinalizeContentObject
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
callback | function | Async function to perform after creating the content draft and before finalizing. Write token is passed as a named parameter. | |
options | object | meta: New metadata for the object - will be merged into existing metadata if specified type: New type for the object - Object ID, version hash or name of type | |
commitMessage | string | Message to include about this commit | |
publish | boolean | If specified, the object will also be published (default:true) | |
awaitCommitConfirmation | boolean | If specified, will wait for the publish commit to be confirmed. Irrelevant if not publishing. (default:true) |
EditContentObject
libraryId,
objectId,
options // optional
}) → Promise.<object>
Create a new content object draft from an existing object.
Returns: Response containing the object ID and write token of the draft, as well as URL of node handling the draft
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
options | object | ||
options.meta | object | New metadata for the object - will be merged into existing metadata if specified | |
options.type | string | New type for the object - Object ID, version hash or name of type |
FinalizeContentObject
libraryId,
objectId,
writeToken,
commitMessage, // optional
publish, // optional
awaitCommitConfirmation // optional
})
Finalize content draft
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
commitMessage | string | Message to include about this commit | |
publish | boolean | If specified, the object will also be published (default:true) | |
awaitCommitConfirmation | boolean | If specified, will wait for the publish commit to be confirmed. Irrelevant if not publishing. (default:true) |
GenerateSignedLinkToken
containerId, // optional
versionHash, // optional
link, // optional
duration // optional
}) → Promise.<string>
Generate a signed link token.
Returns: The state channel token
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
containerId | string | ID of the container object | |
versionHash | string | Version hash of the object | |
link | string | Path | |
duration | string | How long the link should last in milliseconds |
InitializeAuthPolicy
libraryId,
objectId,
writeToken,
target, // optional
body,
version,
description, // optional
id // optional
})
Initialize or replace the signed auth policy for the specified object
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
target | string | The metadata location of the auth policy (default:"auth_policy_spec") | |
body | string | ✓ | The body of the policy |
version | string | ✓ | The version of the policy |
description | string | A description for the policy | |
id | string | The ID of the policy |
MergeMetadata
libraryId,
objectId,
writeToken,
metadata,
metadataSubtree // optional
})
Merge specified metadata into existing content object metadata
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
metadata | Object | ✓ | New metadata to merge |
metadataSubtree | string | Subtree of the object metadata to modify |
PublishContentVersion
libraryId,
objectId,
versionHash,
awaitCommitConfirmation // optional
})
Publish a previously finalized content object version
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
versionHash | string | ✓ | The version hash of the content object to publish |
awaitCommitConfirmation | boolean | If specified, will wait for the publish commit to be confirmed. (default:true) |
RemoveLibraryContentType
libraryId,
typeId, // optional
typeName, // optional
typeHash // optional
}) → Promise.<string>
Remove the specified content type from a library
Returns: Hash of the removeContentType transaction
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
typeId | string | ID of the content type (required unless typeName is specified) | |
typeName | string | Name of the content type (required unless typeId is specified) | |
typeHash | string | Version hash of the content type |
ReplaceMetadata
libraryId,
objectId,
writeToken,
metadata,
metadataSubtree // optional
})
Replace content object metadata with specified metadata
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
metadata | Object | ✓ | New metadata to merge |
metadataSubtree | string | Subtree of the object metadata to modify |
SetAccessCharge
objectId,
accessCharge
})
Set the access charge for the specified object
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
objectId | string | ✓ | ID of the object |
accessCharge | number | string | ✓ | The new access charge, in ether |
SetAuthPolicy
objectId,
policyId
})
Set the authorization policy for the specified object
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
objectId | string | ✓ | The ID of the object |
policyId | string | ✓ | The ID of the policy |
SetContentLibraryImage
libraryId,
writeToken,
image,
imageName // optional
})
Set the image associated with this library
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
writeToken | string | ✓ | Write token for the draft |
image | Blob | ArrayBuffer | Buffer | ✓ | Image to upload |
imageName | string | Name of the image file |
SetContentObjectImage
libraryId,
objectId,
writeToken,
image,
imageName, // optional
imagePath // optional
})
Set the image associated with this object
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ✓ | ID of the library |
objectId | string | ✓ | ID of the object |
writeToken | string | ✓ | Write token of the draft |
image | Blob | ArrayBuffer | Buffer | ✓ | Image to upload |
imageName | string | Name of the image file | |
imagePath | string | Metadata path of the image link (default is recommended) (default:public/display_image) |
SetPermission
objectId,
permission,
writeToken
)
Set the current permission level for the specified object. See client.permissionLevels for all available permissions.
Note: This method is only intended for normal content objects, not types, libraries, etc.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
objectId | string | ✓ | The ID of the object |
permission | string | ✓ | The key for the permission to set - See client.permissionLevels for available permissions |
writeToken | string | ✓ | Write token for the content object - If specified, info will be retrieved from the write draft instead of creating a new draft and finalizing |
UpdateContentObjectGraph
libraryId, // optional
objectId, // optional
versionHash, // optional
callback // optional
)
Recursively update all auto_update links in the specified object.
Note: Links will not be updated unless they are specifically marked as auto_update
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
libraryId | string | ID of the library | |
objectId | string | ID of the object | |
versionHash | string | Version hash of the object -- if not specified, latest version is returned | |
callback | function | If specified, the callback will be called each time an object is updated with current progress as well as information about the last update (action)
|