@sparkvault/sdk-js 1.24.7 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6778,15 +6778,20 @@ class UploadApi extends SparkVaultApi {
6778
6778
  /**
6779
6779
  * Initiate an upload to get Forge URL and ingot ID.
6780
6780
  */
6781
- async initiateUpload(vaultId, filename, sizeBytes, contentType) {
6781
+ async initiateUpload(vaultId, filename, sizeBytes, contentType, token, folder) {
6782
6782
  const url = `${this.config.apiBaseUrl}/v1/files/in/${vaultId}/upload`;
6783
+ const body = {
6784
+ filename,
6785
+ size_bytes: sizeBytes,
6786
+ content_type: contentType,
6787
+ };
6788
+ if (folder) {
6789
+ body.folder_path = folder;
6790
+ }
6783
6791
  const response = await this.request(url, {
6784
6792
  method: 'POST',
6785
- body: JSON.stringify({
6786
- filename,
6787
- size_bytes: sizeBytes,
6788
- content_type: contentType,
6789
- }),
6793
+ body: JSON.stringify(body),
6794
+ headers: token ? { 'X-Vault-Access-Token': token } : undefined,
6790
6795
  });
6791
6796
  if (!isInitiateUploadResponse(response.data)) {
6792
6797
  throw new UploadApiError('Invalid initiate upload response from server', 'invalid_response', response.status);
@@ -9195,7 +9200,7 @@ class UploadRenderer {
9195
9200
  const requestId = generateRequestId();
9196
9201
  try {
9197
9202
  // Initiate upload
9198
- const { forgeUrl, ingotId } = await this.api.initiateUpload(config.vaultId, file.name, file.size, file.type || 'application/octet-stream');
9203
+ const { forgeUrl, ingotId } = await this.api.initiateUpload(config.vaultId, file.name, file.size, file.type || 'application/octet-stream', this.options.token, this.options.folder);
9199
9204
  // Show uploading state
9200
9205
  this.setState({
9201
9206
  view: 'uploading',