Manage files on multiple sites
If your Commerce instance is running multiple sites, the /thirdparty directory supports
creation of site-specific subfolders and files.
This behavior makes it possible for you to have, for example, a different Apple Pay merchant identity certificate for each site, without running into naming conflicts.
For example, suppose you have two sites, siteA and
siteB, and each site requires a unique version of a file named
example.txt. To upload the file for siteA, first use
the startFileUpload endpoint, and set the value of the
x-ccsite header to siteA:
PUT /ccadmin/v1/files HTTP 1.1
Authorization: Bearer <access_token>
x-ccsite: siteA
{
"filename": "example.txt",
"segments": 1,
"uploadtype": "thirdPartyFile"
}
Next, using the token returned in the response, call the
uploadSegment endpoint (with x-ccsite set to
siteA) to upload the file, as described in Upload the file to the desired location.
Once you have uploaded the siteA version of the file, use
startFileUpload and uploadSegment with
x-ccsite set to siteB to create the version of the file
for siteB. If you then view example.txt in your browser,
the version of the file you see will depend on which site’s URL you use.
You can also create a global file by omitting the x-ccsite header
when you call startFileUpload and uploadSegment. When you
use the getFiles endpoint to view a list of files, the files you see depend
on the current site in the request. For example, if you call getFiles without
the x-ccsite header, you see only the global versions of files. If you set
x-ccsite to siteA, you see all
siteA-specific files and folders, as well as any global files and folders
that are not overridden by siteA-specific versions. (If there is both a
global and a siteA-specific version of a file, you see the
siteA-specific version.) Similar logic applies when using the
deleteFile endpoint to delete a file.
Note that since the storefront always has a current site, if there is a site-specific version of a file for the current site as well as a global version of the file, the storefront always sees the site-specific version.