Upload client

Current version: 3.3

The SDK provides an Upload client to upload files using pre-defined configurations to a Sitecore Content Hub instance. The currently supported configurations are:

  • Package import
  • Create asset
  • Update asset main file
  • Update asset alternative file
Warning

This feature is not supported in Content Hub version 4.0.0.

Note

In the following code examples, the client variable refers to the ContentHubClient instance. When using the JavaScript SDK, you can choose your own variable name, but it is called client at instantiation in the docs.

Upload and import a package from a local source

For example, the following snippet uploads and imports a package using the ImportPackageConfiguration:

RequestResponse
const uploadSource = new LocalUploadSource("file://c:/my-package.zip");

const request = new UploadRequest(uploadSource, "ImportPackageConfiguration", "Import");
request.actionParameters = {
    Type: "Package",
};

const result = await client.uploads.uploadAsync(request);

Upload and create an asset from a remote source

For example, the following snippet uploads and creates a new asset using the AssetUploadConfiguration:

RequestResponse
const uploadSource = new HttpUploadSource("https://picsum.photos/200");

const request = new UploadRequest(uploadSource, "AssetUploadConfiguration", "NewAsset");

const result = await client.uploads.uploadAsync(request);

Do you have some feedback for us?

If you have suggestions for improving this article,