@@ -87,6 +87,10 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
87
87
88
88
headers [ " duplex " ] = options. duplex
89
89
90
+ if headers [ " cache-control " ] == nil {
91
+ headers [ " cache-control " ] = " max-age= \( options. cacheControl) "
92
+ }
93
+
90
94
struct UploadResponse : Decodable {
91
95
let Key : String
92
96
let Id : String
@@ -263,7 +267,8 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
263
267
let response = try await execute (
264
268
configuration. url. appendingPathComponent ( " object/sign/ \( bucketId) / \( path) " ) ,
265
269
method: . post,
266
- body: Body ( expiresIn: expiresIn, transform: transform)
270
+ body: Body ( expiresIn: expiresIn, transform: transform) ,
271
+ encoder: JSONParameterEncoder ( encoder: JSONEncoder . unconfiguredEncoder)
267
272
) . serializingDecodable ( SignedURLResponse . self, decoder: configuration. decoder) . value
268
273
269
274
return try makeSignedURL ( response. signedURL, download: download)
@@ -307,7 +312,8 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
307
312
let response = try await execute (
308
313
configuration. url. appendingPathComponent ( " object/sign/ \( bucketId) " ) ,
309
314
method: . post,
310
- body: Params ( expiresIn: expiresIn, paths: paths)
315
+ body: Params ( expiresIn: expiresIn, paths: paths) ,
316
+ encoder: JSONParameterEncoder ( encoder: JSONEncoder . unconfiguredEncoder)
311
317
) . serializingDecodable ( [ SignedURLResponse ] . self, decoder: configuration. decoder) . value
312
318
313
319
return try response. map { try makeSignedURL ( $0. signedURL, download: download) }
@@ -380,7 +386,8 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
380
386
return try await execute (
381
387
configuration. url. appendingPathComponent ( " object/list/ \( bucketId) " ) ,
382
388
method: . post,
383
- body: options
389
+ body: options,
390
+ encoder: JSONParameterEncoder ( encoder: JSONEncoder . unconfiguredEncoder)
384
391
) . serializingDecodable ( [ FileObject ] . self, decoder: configuration. decoder) . value
385
392
}
386
393
@@ -594,16 +601,13 @@ public class StorageFileApi: StorageApi, @unchecked Sendable {
594
601
let options = options ?? defaultFileOptions
595
602
var headers = options. headers. map { HTTPHeaders ( $0) } ?? HTTPHeaders ( )
596
603
604
+ if headers [ " cache-control " ] == nil {
605
+ headers [ " cache-control " ] = " max-age= \( options. cacheControl) "
606
+ }
607
+
597
608
headers [ " x-upsert " ] = " \( options. upsert) "
598
609
headers [ " duplex " ] = options. duplex
599
610
600
- #if DEBUG
601
- let formData = MultipartFormData ( boundary: testingBoundary. value)
602
- #else
603
- let formData = MultipartFormData ( )
604
- #endif
605
- file. encode ( to: formData, withPath: path, options: options)
606
-
607
611
struct UploadResponse : Decodable {
608
612
let Key : String
609
613
}
0 commit comments