@salesforce/b2c-tooling-sdk / operations/jobs / siteArchiveImport
Function: siteArchiveImport()
siteArchiveImport(
instance,target,options):Promise<SiteArchiveImportResult>
Defined in: packages/b2c-tooling-sdk/src/operations/jobs/site-archive.ts:95
Imports a site archive to a B2C Commerce instance.
Supports importing from:
- A local directory (will be zipped automatically)
- A local zip file
- A Buffer containing zip data
- A filename already on the instance (in Impex/src/instance/)
Buffer handling: When passing a Buffer, the archiveName option controls the contract:
- Without
archiveName: The buffer should contain archive entries without a root directory (e.g.libraries/mylib/library.xml). The SDK generates an archive name and wraps the contents under it. - With
archiveName: The buffer must already be correctly structured witharchiveName/as the top-level directory. It is uploaded as-is.
Parameters
instance
B2C instance to import to
target
Source to import (directory path, zip file path, Buffer, or remote filename)
string | Buffer<ArrayBufferLike> | { archiveName?: string; remoteFilename: string; }
options
SiteArchiveImportOptions & object = {}
Import options
Returns
Promise<SiteArchiveImportResult>
Import result with execution details
Throws
JobExecutionError if import job fails
Example
typescript
// Import from a local directory
const result = await siteArchiveImport(instance, './my-site-data');
// Import from a zip file
const result = await siteArchiveImport(instance, './export.zip');
// Import from a buffer (SDK wraps contents automatically)
const zip = new JSZip();
zip.file('libraries/mylib/library.xml', xmlContent);
const buffer = await zip.generateAsync({type: 'nodebuffer'});
const result = await siteArchiveImport(instance, buffer);
// Import from a buffer with explicit archive name (caller owns structure)
const zip = new JSZip();
zip.file('my-import/libraries/mylib/library.xml', xmlContent);
const buffer = await zip.generateAsync({type: 'nodebuffer'});
const result = await siteArchiveImport(instance, buffer, {
archiveName: 'my-import'
});
// Import from existing file on instance
const result = await siteArchiveImport(instance, {
remoteFilename: 'existing-archive.zip'
});