Upload client
This SDK provides a client for uploading files with predefined configurations to a Sitecore Content Hub instance. Supported configurations are:
-
Package import
-
Create asset
-
Update asset main file
-
Update asset alternative file
To upload assets using the SDK, you must have Read permission for the M.UploadConfiguration definition.
The client variable in the following code examples refers to the IMClient instance. When using the Web SDK, you can choose the variable name, but it is also called client at instantiation in the documentation.
Upload and import a package from a local source
For example, the following snippet uploads and imports a package using the ImportPackageConfiguration:
Upload and create an asset from a local file
For example, the following snippet uploads and creates an asset using AssetUploadConfiguration:
Upload and create an asset from a byte array
Do not use the ByteArrayUploadSource to upload local files, because the entire contents will be kept in memory and the underlying array-based implementation has a limit of approximately 2 gigabytes. Instead, use LocalUploadSource.
For example, the following snippet uploads and creates a new asset using the AssetUploadConfiguration:
Upload and create an asset from a remote source
For example, the following snippet uploads and creates an asset using the AssetUploadConfiguration: