Skip to content

Commit 162847a

Browse files
authored
feat(storage): update Storage APIs with StoragePath parameter
2 parents bb7f747 + 45bd603 commit 162847a

File tree

61 files changed

+3287
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3287
-193
lines changed

Amplify/Categories/Storage/Operation/Request/StorageDownloadDataRequest.swift

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,35 @@ import Foundation
1313
/// - Tag: StorageDownloadDataRequest
1414
public struct StorageDownloadDataRequest: AmplifyOperationRequest {
1515

16+
/// The path for the object in storage
17+
///
18+
/// - Tag: StorageDownloadFileRequest.path
19+
public let path: (any StoragePath)?
20+
1621
/// The unique identifier for the object in storage
1722
///
1823
/// - Tag: StorageDownloadDataRequest.key
24+
@available(*, deprecated, message: "Use `path` instead of `key`")
1925
public let key: String
2026

2127
/// Options to adjust the behavior of this request, including plugin-options
2228
///
2329
/// - Tag: StorageDownloadDataRequest.options
2430
public let options: Options
2531

26-
/// - Tag: StorageDownloadDataRequest.key
32+
/// - Tag: StorageDownloadDataRequest.init
33+
@available(*, deprecated, message: "Use init(path:local:options)")
2734
public init(key: String, options: Options) {
2835
self.key = key
2936
self.options = options
37+
self.path = nil
38+
}
39+
40+
/// - Tag: StorageDownloadDataRequest.init
41+
public init(path: any StoragePath, options: Options) {
42+
self.key = ""
43+
self.options = options
44+
self.path = path
3045
}
3146
}
3247

@@ -40,11 +55,13 @@ public extension StorageDownloadDataRequest {
4055
/// Access level of the storage system. Defaults to `public`
4156
///
4257
/// - Tag: StorageDownloadDataRequestOptions.accessLevel
58+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4359
public let accessLevel: StorageAccessLevel
4460

4561
/// Target user to apply the action on.
4662
///
4763
/// - Tag: StorageDownloadDataRequestOptions.targetIdentityId
64+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4865
public let targetIdentityId: String?
4966

5067
/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
@@ -73,12 +90,21 @@ public extension StorageDownloadDataRequest {
7390

7491
///
7592
/// - Tag: StorageDownloadDataRequestOptions.init
93+
@available(*, deprecated, message: "Use init(pluginOptions)")
7694
public init(accessLevel: StorageAccessLevel = .guest,
7795
targetIdentityId: String? = nil,
7896
pluginOptions: Any? = nil) {
7997
self.accessLevel = accessLevel
8098
self.targetIdentityId = targetIdentityId
8199
self.pluginOptions = pluginOptions
82100
}
101+
102+
///
103+
/// - Tag: StorageDownloadDataRequestOptions.init
104+
public init(pluginOptions: Any? = nil) {
105+
self.accessLevel = .guest
106+
self.targetIdentityId = nil
107+
self.pluginOptions = pluginOptions
108+
}
83109
}
84110
}

Amplify/Categories/Storage/Operation/Request/StorageDownloadFileRequest.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ import Foundation
1313
/// - Tag: StorageDownloadFileRequest
1414
public struct StorageDownloadFileRequest: AmplifyOperationRequest {
1515

16+
/// The path for the object in storage
17+
///
18+
/// - Tag: StorageDownloadFileRequest.path
19+
public let path: (any StoragePath)?
20+
1621
/// The unique identifier for the object in storage
1722
///
1823
/// - Tag: StorageDownloadFileRequest.key
24+
@available(*, deprecated, message: "Use `path` instead of `key`")
1925
public let key: String
2026

2127
/// The local file to download the object to
@@ -29,10 +35,20 @@ public struct StorageDownloadFileRequest: AmplifyOperationRequest {
2935
public let options: Options
3036

3137
/// - Tag: StorageDownloadFileRequest.init
38+
@available(*, deprecated, message: "Use init(path:local:options)")
3239
public init(key: String, local: URL, options: Options) {
3340
self.key = key
3441
self.local = local
3542
self.options = options
43+
self.path = nil
44+
}
45+
46+
/// - Tag: StorageDownloadFileRequest.init
47+
public init(path: any StoragePath, local: URL, options: Options) {
48+
self.key = ""
49+
self.local = local
50+
self.options = options
51+
self.path = path
3652
}
3753
}
3854

@@ -46,11 +62,13 @@ public extension StorageDownloadFileRequest {
4662
/// Access level of the storage system. Defaults to `public`
4763
///
4864
/// - Tag: StorageDownloadFileRequestOptions.accessLevel
65+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4966
public let accessLevel: StorageAccessLevel
5067

5168
/// Target user to apply the action on.
5269
///
5370
/// - Tag: StorageDownloadFileRequestOptions.targetIdentityId
71+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
5472
public let targetIdentityId: String?
5573

5674
/// Extra plugin specific options, only used in special circumstances when the existing options do not provide
@@ -61,12 +79,21 @@ public extension StorageDownloadFileRequest {
6179
public let pluginOptions: Any?
6280

6381
/// - Tag: StorageDownloadFileRequestOptions.init
82+
@available(*, deprecated, message: "Use init(pluginOptions)")
6483
public init(accessLevel: StorageAccessLevel = .guest,
6584
targetIdentityId: String? = nil,
6685
pluginOptions: Any? = nil) {
6786
self.accessLevel = accessLevel
6887
self.targetIdentityId = targetIdentityId
6988
self.pluginOptions = pluginOptions
7089
}
90+
91+
/// - Tag: StorageDownloadFileRequestOptions.init
92+
@available(*, deprecated, message: "Use init(pluginOptions)")
93+
public init(pluginOptions: Any? = nil) {
94+
self.accessLevel = .guest
95+
self.targetIdentityId = nil
96+
self.pluginOptions = pluginOptions
97+
}
7198
}
7299
}

Amplify/Categories/Storage/Operation/Request/StorageGetURLRequest.swift

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,63 @@ public struct StorageGetURLRequest: AmplifyOperationRequest {
1414

1515
/// The unique identifier for the object in storage
1616
///
17-
/// - Tag: StorageListRequest.key
17+
/// - Tag: StorageGetURLRequest.key
18+
@available(*, deprecated, message: "Use `path` in Storage API instead of `key`")
1819
public let key: String
1920

20-
/// Options to adjust the behavior of this request, including plugin-options
21+
/// The unique path for the object in storage
22+
///
23+
/// - Tag: StorageGetURLRequest.path
24+
public let path: (any StoragePath)?
25+
26+
/// Options to adjust the behaviour of this request, including plugin-options
2127
///
22-
/// - Tag: StorageListRequest.options
28+
/// - Tag: StorageGetURLRequest.options
2329
public let options: Options
2430

25-
/// - Tag: StorageListRequest.init
31+
/// - Tag: StorageGetURLRequest.init
32+
@available(*, deprecated, message: "Use init(path:options)")
2633
public init(key: String, options: Options) {
2734
self.key = key
2835
self.options = options
36+
self.path = nil
37+
}
38+
39+
/// - Tag: StorageGetURLRequest.init
40+
public init(path: any StoragePath, options: Options) {
41+
self.key = ""
42+
self.options = options
43+
self.path = path
2944
}
3045
}
3146

3247
public extension StorageGetURLRequest {
3348

3449
/// Options to adjust the behavior of this request, including plugin-options
3550
///
36-
/// - Tag: StorageListRequestOptions
51+
/// - Tag: StorageGetURLRequest.Options
3752
struct Options {
3853
/// The default amount of time before the URL expires is 18000 seconds, or 5 hours.
3954
///
40-
/// - Tag: StorageListRequestOptions.defaultExpireInSeconds
55+
/// - Tag: StorageGetURLRequest.Options.defaultExpireInSeconds
4156
public static let defaultExpireInSeconds = 18_000
4257

4358
/// Access level of the storage system. Defaults to `public`
4459
///
45-
/// - Tag: StorageListRequestOptions.accessLevel
60+
/// - Tag: StorageGetURLRequest.Options.accessLevel
61+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4662
public let accessLevel: StorageAccessLevel
4763

4864
/// Target user to apply the action on.
4965
///
50-
/// - Tag: StorageListRequestOptions.targetIdentityId
66+
/// - Tag: StorageGetURLRequest.Options.targetIdentityId
67+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
5168
public let targetIdentityId: String?
5269

5370
/// Number of seconds before the URL expires. Defaults to
5471
/// [defaultExpireInSeconds](x-source-tag://StorageListRequestOptions.defaultExpireInSeconds)
5572
///
56-
/// - Tag: StorageListRequestOptions.expires
73+
/// - Tag: StorageGetURLRequest.Options.expires
5774
public let expires: Int
5875

5976
/// Extra plugin specific options, only used in special circumstances when the existing options do
@@ -62,10 +79,11 @@ public extension StorageGetURLRequest {
6279
/// [AWSStorageGetURLOptions](x-source-tag://AWSStorageGetURLOptions) for
6380
/// expected key/values.
6481
///
65-
/// - Tag: StorageListRequestOptions.pluginOptions
82+
/// - Tag: StorageGetURLRequest.Options.pluginOptions
6683
public let pluginOptions: Any?
6784

68-
/// - Tag: StorageListRequestOptions.init
85+
/// - Tag: StorageGetURLRequest.Options.init
86+
@available(*, deprecated, message: "Use init(expires:pluginOptions)")
6987
public init(accessLevel: StorageAccessLevel = .guest,
7088
targetIdentityId: String? = nil,
7189
expires: Int = Options.defaultExpireInSeconds,
@@ -75,5 +93,14 @@ public extension StorageGetURLRequest {
7593
self.expires = expires
7694
self.pluginOptions = pluginOptions
7795
}
96+
97+
/// - Tag: StorageGetURLRequest.Options.init
98+
public init(expires: Int = Options.defaultExpireInSeconds,
99+
pluginOptions: Any? = nil) {
100+
self.expires = expires
101+
self.pluginOptions = pluginOptions
102+
self.accessLevel = .guest
103+
self.targetIdentityId = nil
104+
}
78105
}
79106
}

Amplify/Categories/Storage/Operation/Request/StorageListRequest.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,22 @@ public struct StorageListRequest: AmplifyOperationRequest {
1515
/// - Tag: StorageListRequest
1616
public let options: Options
1717

18+
/// The unique path for the object in storage
19+
///
20+
/// - Tag: StorageListRequest.path
21+
public let path: (any StoragePath)?
22+
1823
/// - Tag: StorageListRequest.init
24+
@available(*, deprecated, message: "Use init(path:options)")
1925
public init(options: Options) {
2026
self.options = options
27+
self.path = nil
28+
}
29+
30+
/// - Tag: StorageListRequest.init
31+
public init(path: any StoragePath, options: Options) {
32+
self.options = options
33+
self.path = path
2134
}
2235
}
2336

@@ -32,16 +45,19 @@ public extension StorageListRequest {
3245
/// Access level of the storage system. Defaults to `public`
3346
///
3447
/// - Tag: StorageListRequestOptions.accessLevel
48+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
3549
public let accessLevel: StorageAccessLevel
3650

3751
/// Target user to apply the action on
3852
///
3953
/// - Tag: StorageListRequestOptions.targetIdentityId
54+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4055
public let targetIdentityId: String?
4156

4257
/// Path to the keys
4358
///
4459
/// - Tag: StorageListRequestOptions.path
60+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4561
public let path: String?
4662

4763
/// Number between 1 and 1,000 that indicates the limit of how many entries to fetch when

Amplify/Categories/Storage/Operation/Request/StorageRemoveRequest.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,32 @@ public struct StorageRemoveRequest: AmplifyOperationRequest {
1414
/// The unique identifier for the object in storage
1515
///
1616
/// - Tag: StorageRemoveRequest.key
17+
@available(*, deprecated, message: "Use `path` in Storage API instead of `key`")
1718
public let key: String
1819

20+
/// The unique path for the object in storage
21+
///
22+
/// - Tag: StorageRemoveRequest.path
23+
public let path: (any StoragePath)?
24+
1925
/// Options to adjust the behavior of this request, including plugin-options
2026
///
2127
/// - Tag: StorageRemoveRequest.options
2228
public let options: Options
2329

2430
/// - Tag: StorageRemoveRequest.init
31+
@available(*, deprecated, message: "Use init(path:options)")
2532
public init(key: String, options: Options) {
2633
self.key = key
2734
self.options = options
35+
self.path = nil
36+
}
37+
38+
/// - Tag: StorageRemoveRequest.init
39+
public init(path: any StoragePath, options: Options) {
40+
self.key = ""
41+
self.options = options
42+
self.path = path
2843
}
2944
}
3045

@@ -38,6 +53,7 @@ public extension StorageRemoveRequest {
3853
/// Access level of the storage system. Defaults to `public`
3954
///
4055
/// - Tag: StorageRemoveRequestOptions.accessLevel
56+
@available(*, deprecated, message: "Use `path` in Storage API instead of `Options`")
4157
public let accessLevel: StorageAccessLevel
4258

4359
/// Extra plugin specific options, only used in special circumstances when the existing options do not provide

0 commit comments

Comments
 (0)