You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Storage/BucketOptions.swift
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,18 @@
1
1
import Foundation
2
2
3
3
publicstructBucketOptions:Sendable{
4
+
/// The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. Bu default, buckets are private.
4
5
publiclet`public`:Bool
6
+
/// Specifies the allowed mime types that this bucket can accept during upload. The default value is null, which allows files with all mime types to be uploaded. Each mime type specified can be a wildcard, e.g. image/*, or a specific mime type, e.g. image/png.
5
7
publicletfileSizeLimit:String?
8
+
/// Specifies the max file size in bytes that can be uploaded to this bucket. The global file size limit takes precedence over this value. The default value is null, which doesn't set a per bucket file size limit.
Copy file name to clipboardExpand all lines: Sources/Storage/StorageFileApi.swift
+36-44Lines changed: 36 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -124,10 +124,9 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
124
124
125
125
/// Uploads a file to an existing bucket.
126
126
/// - Parameters:
127
-
/// - path: The relative file path. Should be of the format `folder/subfolder/filename.png`. The
128
-
/// bucket must already exist before attempting to upload.
127
+
/// - path: The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
129
128
/// - data: The Data to be stored in the bucket.
130
-
/// - options: HTTP headers. For example `cacheControl`
129
+
/// - options: The options for the uploaded file.
131
130
@discardableResult
132
131
publicfunc upload(
133
132
_ path:String,
@@ -142,6 +141,11 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
142
141
)
143
142
}
144
143
144
+
/// Uploads a file to an existing bucket.
145
+
/// - Parameters:
146
+
/// - path: The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
147
+
/// - fileURL: The file URL to be stored in the bucket.
148
+
/// - options: The options for the uploaded file.
145
149
@discardableResult
146
150
publicfunc upload(
147
151
_ path:String,
@@ -158,10 +162,9 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
158
162
159
163
/// Replaces an existing file at the specified path with a new one.
160
164
/// - Parameters:
161
-
/// - path: The relative file path. Should be of the format `folder/subfolder`. The bucket
162
-
/// already exist before attempting to upload.
165
+
/// - path: The relative file path. Should be of the format `folder/subfolder`. The bucket already exist before attempting to upload.
163
166
/// - data: The Data to be stored in the bucket.
164
-
/// - options: HTTP headers. For example `cacheControl`
167
+
/// - options: The options for the updated file.
165
168
@discardableResult
166
169
publicfunc update(
167
170
_ path:String,
@@ -178,10 +181,9 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
178
181
179
182
/// Replaces an existing file at the specified path with a new one.
180
183
/// - Parameters:
181
-
/// - path: The relative file path. Should be of the format `folder/subfolder`. The bucket
182
-
/// already exist before attempting to upload.
184
+
/// - path: The relative file path. Should be of the format `folder/subfolder`. The bucket already exist before attempting to upload.
183
185
/// - fileURL: The file URL to be stored in the bucket.
184
-
/// - options: HTTP headers. For example `cacheControl`
186
+
/// - options: The options for the updated file.
185
187
@discardableResult
186
188
publicfunc update(
187
189
_ path:String,
@@ -196,10 +198,10 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
196
198
)
197
199
}
198
200
199
-
/// Moves an existing file, optionally renaming it at the same time.
201
+
/// Moves an existing file to a new path.
200
202
/// - Parameters:
201
203
/// - source: The original file path, including the current file name. For example `folder/image.png`.
202
-
/// - destination: The new file path, including the new file name. For example `folder/image-copy.png`.
204
+
/// - destination: The new file path, including the new file name. For example `folder/image-new.png`.
203
205
/// - options: The destination options.
204
206
publicfunc move(
205
207
from source:String,
@@ -222,7 +224,7 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
222
224
)
223
225
}
224
226
225
-
/// Copies an existing file to a new path in the same bucket.
227
+
/// Copies an existing file to a new path.
226
228
/// - Parameters:
227
229
/// - source: The original file path, including the current file name. For example `folder/image.png`.
228
230
/// - destination: The new file path, including the new file name. For example `folder/image-copy.png`.
@@ -255,13 +257,10 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
255
257
.Key
256
258
}
257
259
258
-
/// Create signed url to download file without requiring permissions. This URL can be valid for a
259
-
/// set number of seconds.
260
+
/// Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
260
261
/// - Parameters:
261
-
/// - path: The file path to be downloaded, including the current file name. For example
262
-
/// `folder/image.png`.
263
-
/// - expiresIn: The number of seconds until the signed URL expires. For example, `60` for a URL
264
-
/// which is valid for one minute.
262
+
/// - path: The file path, including the current file name. For example `folder/image.png`.
263
+
/// - expiresIn: The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
265
264
/// - download: Trigger a download with the specified file name.
266
265
/// - transform: Transform the asset before serving it to the client.
267
266
publicfunc createSignedURL(
@@ -291,13 +290,10 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
@@ -490,11 +482,13 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
490
482
}
491
483
}
492
484
493
-
/// Returns a public url for an asset.
485
+
/// A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset. This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
494
486
/// - Parameters:
495
-
/// - path: The file path to the asset. For example `folder/image.png`.
487
+
/// - path: The path and name of the file to generate the public URL for. For example `folder/image.png`.
496
488
/// - download: Trigger a download with the specified file name.
497
489
/// - options: Transform the asset before retrieving it on the client.
490
+
///
491
+
/// - Note: The bucket needs to be set to public, either via ``StorageBucketApi/updateBucket(_:options:)`` or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public".
498
492
publicfunc getPublicURL(
499
493
path:String,
500
494
download:String?=nil,
@@ -527,11 +521,13 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
527
521
return generatedUrl
528
522
}
529
523
530
-
/// Returns a public url for an asset.
524
+
/// A simple convenience function to get the URL for an asset in a public bucket. If you do not want to use this function, you can construct the public URL by concatenating the bucket URL with the path to the asset. This function does not verify if the bucket is public. If a public URL is created for a bucket which is not public, you will not be able to download the asset.
531
525
/// - Parameters:
532
-
/// - path: The file path to the asset. For example `folder/image.png`.
526
+
/// - path: The path and name of the file to generate the public URL for. For example `folder/image.png`.
533
527
/// - download: Trigger a download with the default file name.
534
528
/// - options: Transform the asset before retrieving it on the client.
529
+
///
530
+
/// - Note: The bucket needs to be set to public, either via ``StorageBucketApi/updateBucket(_:options:)`` or by going to Storage on [supabase.com/dashboard](https://supabase.com/dashboard), clicking the overflow menu on a bucket and choosing "Make public".
535
531
publicfunc getPublicURL(
536
532
path:String,
537
533
download:Bool,
@@ -540,14 +536,10 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
/// - Parameter path: The file path, including the current file name. For example
545
-
/// `folder/image.png`.
539
+
/// Creates a signed upload URL. Signed upload URLs can be used to upload files to the bucket without further authentication. They are valid for 2 hours.
540
+
/// - Parameter path: The file path, including the current file name. For example `folder/image.png`.
546
541
/// - Returns: A URL that can be used to upload files to the bucket without further
547
542
/// authentication.
548
-
///
549
-
/// - Note: Signed upload URLs can be used to upload files to the bucket without further
Copy file name to clipboardExpand all lines: Sources/Storage/TransformOptions.swift
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,19 @@
1
1
import Foundation
2
2
3
+
/// Transform the asset before serving it to the client.
3
4
publicstructTransformOptions:Encodable,Sendable{
5
+
/// The width of the image in pixels.
4
6
publicvarwidth:Int?
7
+
/// The height of the image in pixels.
5
8
publicvarheight:Int?
9
+
/// The resize mode can be cover, contain or fill. Defaults to cover.
10
+
/// Cover resizes the image to maintain it's aspect ratio while filling the entire width and height.
11
+
/// Contain resizes the image to maintain it's aspect ratio while fitting the entire image within the width and height.
12
+
/// Fill resizes the image to fill the entire width and height. If the object's aspect ratio does not match the width and height, the image will be stretched to fit.
6
13
publicvarresize:String?
14
+
/// Set the quality of the returned image. A number from 20 to 100, with 100 being the highest quality. Defaults to 80.
0 commit comments