@firecms/core 3.0.0 → 3.0.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.
@@ -21,6 +21,15 @@ export interface UploadFileResult {
21
21
  * Bucket where the file was uploaded
22
22
  */
23
23
  bucket: string;
24
+
25
+ /**
26
+ * Fully qualified storage URL for the uploaded file.
27
+ *
28
+ * For example: `gs://my-bucket/path/to/file.png`.
29
+ *
30
+ * This is optional for backwards compatibility.
31
+ */
32
+ storageUrl?: string;
24
33
  }
25
34
 
26
35
  /**
@@ -134,11 +134,21 @@ export function useStorageUploadController<M extends object>({
134
134
 
135
135
  const onFileUploadComplete = useCallback(async (uploadedPath: string,
136
136
  entry: StorageFieldItem,
137
- metadata?: any) => {
137
+ metadata?: any,
138
+ uploadedUrl?: string) => {
138
139
 
139
140
  console.debug("onFileUploadComplete", uploadedPath, entry);
140
141
 
141
142
  let uploadPathOrDownloadUrl: string | null = uploadedPath;
143
+
144
+ if (storage.includeBucketUrl) {
145
+ if (!uploadedUrl) {
146
+ console.warn("includeBucketUrl is set but no fully-qualified storage URL was returned by the StorageSource. Falling back to the storage path.");
147
+ } else {
148
+ uploadPathOrDownloadUrl = uploadedUrl;
149
+ }
150
+ }
151
+
142
152
  if (storage.storeUrl) {
143
153
  uploadPathOrDownloadUrl = (await storageSource.getDownloadURL(uploadedPath)).url;
144
154
  }