@@ -14,7 +14,7 @@ final class StorageFileIntegrationTests: XCTestCase {
1414 configuration: StorageClientConfiguration (
1515 url: URL ( string: " \( DotEnv . SUPABASE_URL) /storage/v1 " ) !,
1616 headers: [
17- " Authorization " : " Bearer \( DotEnv . SUPABASE_SERVICE_ROLE_KEY) " ,
17+ " Authorization " : " Bearer \( DotEnv . SUPABASE_SERVICE_ROLE_KEY) "
1818 ] ,
1919 logger: nil
2020 )
@@ -56,7 +56,8 @@ final class StorageFileIntegrationTests: XCTestCase {
5656 }
5757
5858 func testGetPublicURLWithCustomDownload( ) throws {
59- let publicURL = try storage. from ( bucketName) . getPublicURL ( path: uploadPath, download: " test.jpg " )
59+ let publicURL = try storage. from ( bucketName) . getPublicURL (
60+ path: uploadPath, download: " test.jpg " )
6061 XCTAssertEqual (
6162 publicURL. absoluteString,
6263 " \( DotEnv . SUPABASE_URL) /storage/v1/object/public/ \( bucketName) / \( uploadPath) ?download=test.jpg "
@@ -68,26 +69,31 @@ final class StorageFileIntegrationTests: XCTestCase {
6869
6970 let url = try await storage. from ( bucketName) . createSignedURL ( path: uploadPath, expiresIn: 2000 )
7071 XCTAssertTrue (
71- url. absoluteString. contains ( " \( DotEnv . SUPABASE_URL) /storage/v1/object/sign/ \( bucketName) / \( uploadPath) " )
72+ url. absoluteString. contains (
73+ " \( DotEnv . SUPABASE_URL) /storage/v1/object/sign/ \( bucketName) / \( uploadPath) " )
7274 )
7375 }
7476
7577 func testSignURL_withDownloadQueryString( ) async throws {
7678 _ = try await storage. from ( bucketName) . upload ( uploadPath, data: file)
7779
78- let url = try await storage. from ( bucketName) . createSignedURL ( path: uploadPath, expiresIn: 2000 , download: true )
80+ let url = try await storage. from ( bucketName) . createSignedURL (
81+ path: uploadPath, expiresIn: 2000 , download: true )
7982 XCTAssertTrue (
80- url. absoluteString. contains ( " \( DotEnv . SUPABASE_URL) /storage/v1/object/sign/ \( bucketName) / \( uploadPath) " )
83+ url. absoluteString. contains (
84+ " \( DotEnv . SUPABASE_URL) /storage/v1/object/sign/ \( bucketName) / \( uploadPath) " )
8185 )
8286 XCTAssertTrue ( url. absoluteString. contains ( " &download= " ) )
8387 }
8488
8589 func testSignURL_withCustomFilenameForDownload( ) async throws {
8690 _ = try await storage. from ( bucketName) . upload ( uploadPath, data: file)
8791
88- let url = try await storage. from ( bucketName) . createSignedURL ( path: uploadPath, expiresIn: 2000 , download: " test.jpg " )
92+ let url = try await storage. from ( bucketName) . createSignedURL (
93+ path: uploadPath, expiresIn: 2000 , download: " test.jpg " )
8994 XCTAssertTrue (
90- url. absoluteString. contains ( " \( DotEnv . SUPABASE_URL) /storage/v1/object/sign/ \( bucketName) / \( uploadPath) " )
95+ url. absoluteString. contains (
96+ " \( DotEnv . SUPABASE_URL) /storage/v1/object/sign/ \( bucketName) / \( uploadPath) " )
9197 )
9298 XCTAssertTrue ( url. absoluteString. contains ( " &download=test.jpg " ) )
9399 }
@@ -192,15 +198,18 @@ final class StorageFileIntegrationTests: XCTestCase {
192198 func testCanUploadWithSignedURLForUpload( ) async throws {
193199 let res = try await storage. from ( bucketName) . createSignedUploadURL ( path: uploadPath)
194200
195- let uploadRes = try await storage. from ( bucketName) . uploadToSignedURL ( res. path, token: res. token, data: file)
201+ let uploadRes = try await storage. from ( bucketName) . uploadToSignedURL (
202+ res. path, token: res. token, data: file)
196203 XCTAssertEqual ( uploadRes. path, uploadPath)
197204 }
198205
199206 func testCanUploadOverwritingFilesWithSignedURL( ) async throws {
200207 try await storage. from ( bucketName) . upload ( uploadPath, data: file)
201208
202- let res = try await storage. from ( bucketName) . createSignedUploadURL ( path: uploadPath, options: CreateSignedUploadURLOptions ( upsert: true ) )
203- let uploadRes = try await storage. from ( bucketName) . uploadToSignedURL ( res. path, token: res. token, data: file)
209+ let res = try await storage. from ( bucketName) . createSignedUploadURL (
210+ path: uploadPath, options: CreateSignedUploadURLOptions ( upsert: true ) )
211+ let uploadRes = try await storage. from ( bucketName) . uploadToSignedURL (
212+ res. path, token: res. token, data: file)
204213 XCTAssertEqual ( uploadRes. path, uploadPath)
205214 }
206215
@@ -353,6 +362,24 @@ final class StorageFileIntegrationTests: XCTestCase {
353362 XCTAssertFalse ( exists)
354363 }
355364
365+ func testUploadWithCacheControl( ) async throws {
366+ try await storage. from ( bucketName) . upload (
367+ uploadPath,
368+ data: file,
369+ options: FileOptions (
370+ cacheControl: " 14400 "
371+ )
372+ )
373+
374+ let publicURL = try storage. from ( bucketName) . getPublicURL ( path: uploadPath)
375+
376+ let ( _, response) = try await URLSession . shared. data ( from: publicURL)
377+ let httpResponse = try XCTUnwrap ( response as? HTTPURLResponse )
378+ let cacheControl = try XCTUnwrap ( httpResponse. value ( forHTTPHeaderField: " cache-control " ) )
379+
380+ XCTAssertEqual ( cacheControl, " public, max-age=14400 " )
381+ }
382+
356383 private func newBucket(
357384 prefix: String = " " ,
358385 options: BucketOptions = BucketOptions ( public: true )
0 commit comments