@sparkvault/sdk-js 1.24.7 → 1.25.1

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);
@@ -7144,6 +7149,8 @@ function getUploadStyles(options) {
7144
7149
  .svu-drop-icon {
7145
7150
  color: ${tokens.textMuted};
7146
7151
  margin-bottom: 12px;
7152
+ display: flex;
7153
+ justify-content: center;
7147
7154
  }
7148
7155
 
7149
7156
  .svu-drop-text {
@@ -9195,7 +9202,7 @@ class UploadRenderer {
9195
9202
  const requestId = generateRequestId();
9196
9203
  try {
9197
9204
  // Initiate upload
9198
- const { forgeUrl, ingotId } = await this.api.initiateUpload(config.vaultId, file.name, file.size, file.type || 'application/octet-stream');
9205
+ 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
9206
  // Show uploading state
9200
9207
  this.setState({
9201
9208
  view: 'uploading',