appwrite 2.4.1 → 4.1.0
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.
- checksums.yaml +4 -4
- data/lib/appwrite/client.rb +209 -56
- data/lib/appwrite/exception.rb +7 -7
- data/lib/appwrite/file.rb +9 -15
- data/lib/appwrite/models/attribute_boolean.rb +52 -0
- data/lib/appwrite/models/attribute_email.rb +57 -0
- data/lib/appwrite/models/attribute_enum.rb +62 -0
- data/lib/appwrite/models/attribute_float.rb +62 -0
- data/lib/appwrite/models/attribute_integer.rb +62 -0
- data/lib/appwrite/models/attribute_ip.rb +57 -0
- data/lib/appwrite/models/attribute_list.rb +32 -0
- data/lib/appwrite/models/attribute_string.rb +57 -0
- data/lib/appwrite/models/attribute_url.rb +57 -0
- data/lib/appwrite/models/bucket.rb +82 -0
- data/lib/appwrite/models/bucket_list.rb +32 -0
- data/lib/appwrite/models/collection.rb +62 -0
- data/lib/appwrite/models/collection_list.rb +32 -0
- data/lib/appwrite/models/continent.rb +32 -0
- data/lib/appwrite/models/continent_list.rb +32 -0
- data/lib/appwrite/models/country.rb +32 -0
- data/lib/appwrite/models/country_list.rb +32 -0
- data/lib/appwrite/models/currency.rb +57 -0
- data/lib/appwrite/models/currency_list.rb +32 -0
- data/lib/appwrite/models/deployment.rb +77 -0
- data/lib/appwrite/models/deployment_list.rb +32 -0
- data/lib/appwrite/models/document.rb +50 -0
- data/lib/appwrite/models/document_list.rb +36 -0
- data/lib/appwrite/models/execution.rb +72 -0
- data/lib/appwrite/models/execution_list.rb +32 -0
- data/lib/appwrite/models/file.rb +77 -0
- data/lib/appwrite/models/file_list.rb +32 -0
- data/lib/appwrite/models/function.rb +92 -0
- data/lib/appwrite/models/function_list.rb +32 -0
- data/lib/appwrite/models/health_antivirus.rb +32 -0
- data/lib/appwrite/models/health_queue.rb +27 -0
- data/lib/appwrite/models/health_status.rb +32 -0
- data/lib/appwrite/models/health_time.rb +37 -0
- data/lib/appwrite/models/index.rb +47 -0
- data/lib/appwrite/models/index_list.rb +32 -0
- data/lib/appwrite/models/language.rb +37 -0
- data/lib/appwrite/models/language_list.rb +32 -0
- data/lib/appwrite/models/locale.rb +57 -0
- data/lib/appwrite/models/log.rb +127 -0
- data/lib/appwrite/models/log_list.rb +32 -0
- data/lib/appwrite/models/membership.rb +67 -0
- data/lib/appwrite/models/membership_list.rb +32 -0
- data/lib/appwrite/models/phone.rb +37 -0
- data/lib/appwrite/models/phone_list.rb +32 -0
- data/lib/appwrite/models/preferences.rb +30 -0
- data/lib/appwrite/models/runtime.rb +57 -0
- data/lib/appwrite/models/runtime_list.rb +32 -0
- data/lib/appwrite/models/session.rb +142 -0
- data/lib/appwrite/models/session_list.rb +32 -0
- data/lib/appwrite/models/team.rb +42 -0
- data/lib/appwrite/models/team_list.rb +32 -0
- data/lib/appwrite/models/token.rb +42 -0
- data/lib/appwrite/models/user.rb +62 -0
- data/lib/appwrite/models/user_list.rb +32 -0
- data/lib/appwrite/query.rb +42 -0
- data/lib/appwrite/service.rb +0 -5
- data/lib/appwrite/services/account.rb +400 -138
- data/lib/appwrite/services/avatars.rb +188 -125
- data/lib/appwrite/services/database.rb +875 -130
- data/lib/appwrite/services/functions.rb +441 -207
- data/lib/appwrite/services/health.rb +201 -58
- data/lib/appwrite/services/locale.rb +133 -32
- data/lib/appwrite/services/storage.rb +471 -118
- data/lib/appwrite/services/teams.rb +302 -118
- data/lib/appwrite/services/users.rb +322 -127
- data/lib/appwrite.rb +57 -0
- metadata +74 -111
- data/.github/ISSUE_TEMPLATE/bug.yaml +0 -82
- data/.github/ISSUE_TEMPLATE/documentation.yaml +0 -32
- data/.github/ISSUE_TEMPLATE/feature.yaml +0 -40
- data/.travis.yml +0 -16
- data/CHANGELOG.md +0 -1
- data/Gemfile +0 -4
- data/LICENSE +0 -12
- data/README.md +0 -96
- data/appwrite.gemspec +0 -11
- data/docs/examples/account/create-recovery.md +0 -15
- data/docs/examples/account/create-verification.md +0 -15
- data/docs/examples/account/delete-session.md +0 -15
- data/docs/examples/account/delete-sessions.md +0 -15
- data/docs/examples/account/delete.md +0 -15
- data/docs/examples/account/get-logs.md +0 -15
- data/docs/examples/account/get-prefs.md +0 -15
- data/docs/examples/account/get-session.md +0 -15
- data/docs/examples/account/get-sessions.md +0 -15
- data/docs/examples/account/get.md +0 -15
- data/docs/examples/account/update-email.md +0 -15
- data/docs/examples/account/update-name.md +0 -15
- data/docs/examples/account/update-password.md +0 -15
- data/docs/examples/account/update-prefs.md +0 -15
- data/docs/examples/account/update-recovery.md +0 -15
- data/docs/examples/account/update-verification.md +0 -15
- data/docs/examples/avatars/get-browser.md +0 -15
- data/docs/examples/avatars/get-credit-card.md +0 -15
- data/docs/examples/avatars/get-favicon.md +0 -15
- data/docs/examples/avatars/get-flag.md +0 -15
- data/docs/examples/avatars/get-image.md +0 -15
- data/docs/examples/avatars/get-initials.md +0 -15
- data/docs/examples/avatars/get-q-r.md +0 -15
- data/docs/examples/database/create-collection.md +0 -15
- data/docs/examples/database/create-document.md +0 -15
- data/docs/examples/database/delete-collection.md +0 -15
- data/docs/examples/database/delete-document.md +0 -15
- data/docs/examples/database/get-collection.md +0 -15
- data/docs/examples/database/get-document.md +0 -15
- data/docs/examples/database/list-collections.md +0 -15
- data/docs/examples/database/list-documents.md +0 -15
- data/docs/examples/database/update-collection.md +0 -15
- data/docs/examples/database/update-document.md +0 -15
- data/docs/examples/functions/create-execution.md +0 -15
- data/docs/examples/functions/create-tag.md +0 -15
- data/docs/examples/functions/create.md +0 -15
- data/docs/examples/functions/delete-tag.md +0 -15
- data/docs/examples/functions/delete.md +0 -15
- data/docs/examples/functions/get-execution.md +0 -15
- data/docs/examples/functions/get-tag.md +0 -15
- data/docs/examples/functions/get.md +0 -15
- data/docs/examples/functions/list-executions.md +0 -15
- data/docs/examples/functions/list-tags.md +0 -15
- data/docs/examples/functions/list.md +0 -15
- data/docs/examples/functions/update-tag.md +0 -15
- data/docs/examples/functions/update.md +0 -15
- data/docs/examples/health/get-anti-virus.md +0 -15
- data/docs/examples/health/get-cache.md +0 -15
- data/docs/examples/health/get-d-b.md +0 -15
- data/docs/examples/health/get-queue-certificates.md +0 -15
- data/docs/examples/health/get-queue-functions.md +0 -15
- data/docs/examples/health/get-queue-logs.md +0 -15
- data/docs/examples/health/get-queue-tasks.md +0 -15
- data/docs/examples/health/get-queue-usage.md +0 -15
- data/docs/examples/health/get-queue-webhooks.md +0 -15
- data/docs/examples/health/get-storage-local.md +0 -15
- data/docs/examples/health/get-time.md +0 -15
- data/docs/examples/health/get.md +0 -15
- data/docs/examples/locale/get-continents.md +0 -15
- data/docs/examples/locale/get-countries-e-u.md +0 -15
- data/docs/examples/locale/get-countries-phones.md +0 -15
- data/docs/examples/locale/get-countries.md +0 -15
- data/docs/examples/locale/get-currencies.md +0 -15
- data/docs/examples/locale/get-languages.md +0 -15
- data/docs/examples/locale/get.md +0 -15
- data/docs/examples/storage/create-file.md +0 -15
- data/docs/examples/storage/delete-file.md +0 -15
- data/docs/examples/storage/get-file-download.md +0 -15
- data/docs/examples/storage/get-file-preview.md +0 -15
- data/docs/examples/storage/get-file-view.md +0 -15
- data/docs/examples/storage/get-file.md +0 -15
- data/docs/examples/storage/list-files.md +0 -15
- data/docs/examples/storage/update-file.md +0 -15
- data/docs/examples/teams/create-membership.md +0 -15
- data/docs/examples/teams/create.md +0 -15
- data/docs/examples/teams/delete-membership.md +0 -15
- data/docs/examples/teams/delete.md +0 -15
- data/docs/examples/teams/get-memberships.md +0 -15
- data/docs/examples/teams/get.md +0 -15
- data/docs/examples/teams/list.md +0 -15
- data/docs/examples/teams/update-membership-roles.md +0 -15
- data/docs/examples/teams/update-membership-status.md +0 -15
- data/docs/examples/teams/update.md +0 -15
- data/docs/examples/users/create.md +0 -15
- data/docs/examples/users/delete-session.md +0 -15
- data/docs/examples/users/delete-sessions.md +0 -15
- data/docs/examples/users/delete.md +0 -15
- data/docs/examples/users/get-logs.md +0 -15
- data/docs/examples/users/get-prefs.md +0 -15
- data/docs/examples/users/get-sessions.md +0 -15
- data/docs/examples/users/get.md +0 -15
- data/docs/examples/users/list.md +0 -15
- data/docs/examples/users/update-email.md +0 -15
- data/docs/examples/users/update-name.md +0 -15
- data/docs/examples/users/update-password.md +0 -15
- data/docs/examples/users/update-prefs.md +0 -15
- data/docs/examples/users/update-status.md +0 -15
- data/docs/examples/users/update-verification.md +0 -15
|
@@ -1,211 +1,564 @@
|
|
|
1
|
+
#frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Appwrite
|
|
2
4
|
class Storage < Service
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
# Get a list of all the storage buckets. You can use the query params to
|
|
7
|
+
# filter your results.
|
|
8
|
+
#
|
|
9
|
+
# @param [string] search Search term to filter your list results. Max length: 256 chars.
|
|
10
|
+
# @param [number] limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
|
11
|
+
# @param [number] offset Results offset. The default value is 0. Use this param to manage pagination.
|
|
12
|
+
# @param [string] cursor ID of the bucket used as the starting point for the query, excluding the bucket itself. Should be used for efficient pagination when working with large sets of data.
|
|
13
|
+
# @param [string] cursor_direction Direction of the cursor.
|
|
14
|
+
# @param [string] order_type Order result by ASC or DESC order.
|
|
15
|
+
#
|
|
16
|
+
# @return [BucketList]
|
|
17
|
+
def list_buckets(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
|
|
18
|
+
path = '/storage/buckets'
|
|
19
|
+
|
|
20
|
+
params = {
|
|
21
|
+
search: search,
|
|
22
|
+
limit: limit,
|
|
23
|
+
offset: offset,
|
|
24
|
+
cursor: cursor,
|
|
25
|
+
cursorDirection: cursor_direction,
|
|
26
|
+
orderType: order_type,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
headers = {
|
|
30
|
+
"content-type": 'application/json',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@client.call(
|
|
34
|
+
method: 'GET',
|
|
35
|
+
path: path,
|
|
36
|
+
headers: headers,
|
|
37
|
+
params: params,
|
|
38
|
+
response_type: Models::BucketList
|
|
39
|
+
)
|
|
40
|
+
end
|
|
12
41
|
|
|
13
|
-
|
|
14
|
-
|
|
42
|
+
# Create a new storage bucket.
|
|
43
|
+
#
|
|
44
|
+
# @param [string] bucket_id Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
45
|
+
# @param [string] name Bucket name
|
|
46
|
+
# @param [string] permission Permissions type model to use for reading files in this bucket. You can use bucket-level permission set once on the bucket using the `read` and `write` params, or you can set file-level permission where each file read and write params will decide who has access to read and write to each file individually. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
|
47
|
+
# @param [array] read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
|
48
|
+
# @param [array] write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
|
49
|
+
# @param [boolean] enabled Is bucket enabled?
|
|
50
|
+
# @param [number] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the `_APP_STORAGE_LIMIT` environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)
|
|
51
|
+
# @param [array] allowed_file_extensions Allowed file extensions
|
|
52
|
+
# @param [boolean] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
|
53
|
+
# @param [boolean] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
|
54
|
+
#
|
|
55
|
+
# @return [Bucket]
|
|
56
|
+
def create_bucket(bucket_id:, name:, permission:, read: nil, write: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, encryption: nil, antivirus: nil)
|
|
57
|
+
if bucket_id.nil?
|
|
58
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
15
59
|
end
|
|
16
60
|
|
|
17
|
-
if
|
|
18
|
-
|
|
61
|
+
if name.nil?
|
|
62
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
|
19
63
|
end
|
|
20
64
|
|
|
21
|
-
if
|
|
22
|
-
|
|
65
|
+
if permission.nil?
|
|
66
|
+
raise Appwrite::Exception.new('Missing required parameter: "permission"')
|
|
23
67
|
end
|
|
24
68
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
69
|
+
path = '/storage/buckets'
|
|
70
|
+
|
|
71
|
+
params = {
|
|
72
|
+
bucketId: bucket_id,
|
|
73
|
+
name: name,
|
|
74
|
+
permission: permission,
|
|
75
|
+
read: read,
|
|
76
|
+
write: write,
|
|
77
|
+
enabled: enabled,
|
|
78
|
+
maximumFileSize: maximum_file_size,
|
|
79
|
+
allowedFileExtensions: allowed_file_extensions,
|
|
80
|
+
encryption: encryption,
|
|
81
|
+
antivirus: antivirus,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
headers = {
|
|
85
|
+
"content-type": 'application/json',
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@client.call(
|
|
89
|
+
method: 'POST',
|
|
90
|
+
path: path,
|
|
91
|
+
headers: headers,
|
|
92
|
+
params: params,
|
|
93
|
+
response_type: Models::Bucket
|
|
94
|
+
)
|
|
28
95
|
end
|
|
29
96
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
97
|
+
# Get a storage bucket by its unique ID. This endpoint response returns a
|
|
98
|
+
# JSON object with the storage bucket metadata.
|
|
99
|
+
#
|
|
100
|
+
# @param [string] bucket_id Bucket unique ID.
|
|
101
|
+
#
|
|
102
|
+
# @return [Bucket]
|
|
103
|
+
def get_bucket(bucket_id:)
|
|
104
|
+
if bucket_id.nil?
|
|
105
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
33
106
|
end
|
|
34
107
|
|
|
35
|
-
path = '/storage/
|
|
108
|
+
path = '/storage/buckets/{bucketId}'
|
|
109
|
+
.gsub('{bucketId}', bucket_id)
|
|
36
110
|
|
|
37
|
-
params = {
|
|
111
|
+
params = {
|
|
112
|
+
}
|
|
38
113
|
|
|
39
|
-
|
|
40
|
-
|
|
114
|
+
headers = {
|
|
115
|
+
"content-type": 'application/json',
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@client.call(
|
|
119
|
+
method: 'GET',
|
|
120
|
+
path: path,
|
|
121
|
+
headers: headers,
|
|
122
|
+
params: params,
|
|
123
|
+
response_type: Models::Bucket
|
|
124
|
+
)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Update a storage bucket by its unique ID.
|
|
128
|
+
#
|
|
129
|
+
# @param [string] bucket_id Bucket unique ID.
|
|
130
|
+
# @param [string] name Bucket name
|
|
131
|
+
# @param [string] permission Permissions type model to use for reading files in this bucket. You can use bucket-level permission set once on the bucket using the `read` and `write` params, or you can set file-level permission where each file read and write params will decide who has access to read and write to each file individually. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
|
132
|
+
# @param [array] read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
|
133
|
+
# @param [array] write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
|
134
|
+
# @param [boolean] enabled Is bucket enabled?
|
|
135
|
+
# @param [number] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)
|
|
136
|
+
# @param [array] allowed_file_extensions Allowed file extensions
|
|
137
|
+
# @param [boolean] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
|
138
|
+
# @param [boolean] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
|
139
|
+
#
|
|
140
|
+
# @return [Bucket]
|
|
141
|
+
def update_bucket(bucket_id:, name:, permission:, read: nil, write: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, encryption: nil, antivirus: nil)
|
|
142
|
+
if bucket_id.nil?
|
|
143
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
41
144
|
end
|
|
42
145
|
|
|
43
|
-
if
|
|
44
|
-
|
|
146
|
+
if name.nil?
|
|
147
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
|
45
148
|
end
|
|
46
149
|
|
|
47
|
-
if
|
|
48
|
-
|
|
150
|
+
if permission.nil?
|
|
151
|
+
raise Appwrite::Exception.new('Missing required parameter: "permission"')
|
|
49
152
|
end
|
|
50
153
|
|
|
51
|
-
|
|
52
|
-
'
|
|
53
|
-
|
|
154
|
+
path = '/storage/buckets/{bucketId}'
|
|
155
|
+
.gsub('{bucketId}', bucket_id)
|
|
156
|
+
|
|
157
|
+
params = {
|
|
158
|
+
name: name,
|
|
159
|
+
permission: permission,
|
|
160
|
+
read: read,
|
|
161
|
+
write: write,
|
|
162
|
+
enabled: enabled,
|
|
163
|
+
maximumFileSize: maximum_file_size,
|
|
164
|
+
allowedFileExtensions: allowed_file_extensions,
|
|
165
|
+
encryption: encryption,
|
|
166
|
+
antivirus: antivirus,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
headers = {
|
|
170
|
+
"content-type": 'application/json',
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@client.call(
|
|
174
|
+
method: 'PUT',
|
|
175
|
+
path: path,
|
|
176
|
+
headers: headers,
|
|
177
|
+
params: params,
|
|
178
|
+
response_type: Models::Bucket
|
|
179
|
+
)
|
|
54
180
|
end
|
|
55
181
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
182
|
+
# Delete a storage bucket by its unique ID.
|
|
183
|
+
#
|
|
184
|
+
# @param [string] bucket_id Bucket unique ID.
|
|
185
|
+
#
|
|
186
|
+
# @return []
|
|
187
|
+
def delete_bucket(bucket_id:)
|
|
188
|
+
if bucket_id.nil?
|
|
189
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
59
190
|
end
|
|
60
191
|
|
|
61
|
-
path = '/storage/
|
|
62
|
-
.gsub('{
|
|
192
|
+
path = '/storage/buckets/{bucketId}'
|
|
193
|
+
.gsub('{bucketId}', bucket_id)
|
|
194
|
+
|
|
195
|
+
params = {
|
|
196
|
+
}
|
|
63
197
|
|
|
64
|
-
|
|
198
|
+
headers = {
|
|
199
|
+
"content-type": 'application/json',
|
|
200
|
+
}
|
|
65
201
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
202
|
+
@client.call(
|
|
203
|
+
method: 'DELETE',
|
|
204
|
+
path: path,
|
|
205
|
+
headers: headers,
|
|
206
|
+
params: params,
|
|
207
|
+
)
|
|
69
208
|
end
|
|
70
209
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
210
|
+
# Get a list of all the user files. You can use the query params to filter
|
|
211
|
+
# your results. On admin mode, this endpoint will return a list of all of the
|
|
212
|
+
# project's files. [Learn more about different API modes](/docs/admin).
|
|
213
|
+
#
|
|
214
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
215
|
+
# @param [string] search Search term to filter your list results. Max length: 256 chars.
|
|
216
|
+
# @param [number] limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
|
217
|
+
# @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
|
|
218
|
+
# @param [string] cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
|
|
219
|
+
# @param [string] cursor_direction Direction of the cursor.
|
|
220
|
+
# @param [string] order_type Order result by ASC or DESC order.
|
|
221
|
+
#
|
|
222
|
+
# @return [FileList]
|
|
223
|
+
def list_files(bucket_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
|
|
224
|
+
if bucket_id.nil?
|
|
225
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
74
226
|
end
|
|
75
227
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
228
|
+
path = '/storage/buckets/{bucketId}/files'
|
|
229
|
+
.gsub('{bucketId}', bucket_id)
|
|
230
|
+
|
|
231
|
+
params = {
|
|
232
|
+
search: search,
|
|
233
|
+
limit: limit,
|
|
234
|
+
offset: offset,
|
|
235
|
+
cursor: cursor,
|
|
236
|
+
cursorDirection: cursor_direction,
|
|
237
|
+
orderType: order_type,
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
headers = {
|
|
241
|
+
"content-type": 'application/json',
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
@client.call(
|
|
245
|
+
method: 'GET',
|
|
246
|
+
path: path,
|
|
247
|
+
headers: headers,
|
|
248
|
+
params: params,
|
|
249
|
+
response_type: Models::FileList
|
|
250
|
+
)
|
|
251
|
+
end
|
|
79
252
|
|
|
80
|
-
|
|
81
|
-
|
|
253
|
+
# Create a new file. Before using this route, you should create a new bucket
|
|
254
|
+
# resource using either a [server
|
|
255
|
+
# integration](/docs/server/database#storageCreateBucket) API or directly
|
|
256
|
+
# from your Appwrite console.
|
|
257
|
+
#
|
|
258
|
+
# Larger files should be uploaded using multiple requests with the
|
|
259
|
+
# [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
|
|
260
|
+
# header to send a partial request with a maximum supported chunk of `5MB`.
|
|
261
|
+
# The `content-range` header values should always be in bytes.
|
|
262
|
+
#
|
|
263
|
+
# When the first request is sent, the server will return the **File** object,
|
|
264
|
+
# and the subsequent part request must include the file's **id** in
|
|
265
|
+
# `x-appwrite-id` header to allow the server to know that the partial upload
|
|
266
|
+
# is for the existing file and not for a new one.
|
|
267
|
+
#
|
|
268
|
+
# If you're creating a new file using one of the Appwrite SDKs, all the
|
|
269
|
+
# chunking logic will be managed by the SDK internally.
|
|
270
|
+
#
|
|
271
|
+
#
|
|
272
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
273
|
+
# @param [string] file_id File ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
|
274
|
+
# @param [file] file Binary file.
|
|
275
|
+
# @param [array] read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
276
|
+
# @param [array] write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
277
|
+
#
|
|
278
|
+
# @return [File]
|
|
279
|
+
def create_file(bucket_id:, file_id:, file:, read: nil, write: nil, on_progress: nil)
|
|
280
|
+
if bucket_id.nil?
|
|
281
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
82
282
|
end
|
|
83
283
|
|
|
84
|
-
|
|
85
|
-
.
|
|
86
|
-
|
|
87
|
-
params = {}
|
|
88
|
-
|
|
89
|
-
if !read.nil?
|
|
90
|
-
params[:read] = read
|
|
284
|
+
if file_id.nil?
|
|
285
|
+
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
91
286
|
end
|
|
92
287
|
|
|
93
|
-
if
|
|
94
|
-
|
|
288
|
+
if file.nil?
|
|
289
|
+
raise Appwrite::Exception.new('Missing required parameter: "file"')
|
|
95
290
|
end
|
|
96
291
|
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
|
|
292
|
+
path = '/storage/buckets/{bucketId}/files'
|
|
293
|
+
.gsub('{bucketId}', bucket_id)
|
|
294
|
+
|
|
295
|
+
params = {
|
|
296
|
+
fileId: file_id,
|
|
297
|
+
file: file,
|
|
298
|
+
read: read,
|
|
299
|
+
write: write,
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
headers = {
|
|
303
|
+
"content-type": 'multipart/form-data',
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
id_param_name = "fileId"
|
|
307
|
+
param_name = 'file'
|
|
308
|
+
|
|
309
|
+
@client.chunked_upload(
|
|
310
|
+
path: path,
|
|
311
|
+
headers: headers,
|
|
312
|
+
params: params,
|
|
313
|
+
param_name: param_name,
|
|
314
|
+
id_param_name: id_param_name,
|
|
315
|
+
on_progress: on_progress,
|
|
316
|
+
response_type: Models::File
|
|
317
|
+
)
|
|
100
318
|
end
|
|
101
319
|
|
|
102
|
-
|
|
320
|
+
# Get a file by its unique ID. This endpoint response returns a JSON object
|
|
321
|
+
# with the file metadata.
|
|
322
|
+
#
|
|
323
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
324
|
+
# @param [string] file_id File ID.
|
|
325
|
+
#
|
|
326
|
+
# @return [File]
|
|
327
|
+
def get_file(bucket_id:, file_id:)
|
|
328
|
+
if bucket_id.nil?
|
|
329
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
330
|
+
end
|
|
331
|
+
|
|
103
332
|
if file_id.nil?
|
|
104
333
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
105
334
|
end
|
|
106
335
|
|
|
107
|
-
path = '/storage/files/{fileId}'
|
|
336
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
|
337
|
+
.gsub('{bucketId}', bucket_id)
|
|
108
338
|
.gsub('{fileId}', file_id)
|
|
109
339
|
|
|
110
|
-
params = {
|
|
340
|
+
params = {
|
|
341
|
+
}
|
|
111
342
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
343
|
+
headers = {
|
|
344
|
+
"content-type": 'application/json',
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
@client.call(
|
|
348
|
+
method: 'GET',
|
|
349
|
+
path: path,
|
|
350
|
+
headers: headers,
|
|
351
|
+
params: params,
|
|
352
|
+
response_type: Models::File
|
|
353
|
+
)
|
|
115
354
|
end
|
|
116
355
|
|
|
117
|
-
|
|
356
|
+
# Update a file by its unique ID. Only users with write permissions have
|
|
357
|
+
# access to update this resource.
|
|
358
|
+
#
|
|
359
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
360
|
+
# @param [string] file_id File unique ID.
|
|
361
|
+
# @param [array] read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
362
|
+
# @param [array] write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
|
363
|
+
#
|
|
364
|
+
# @return [File]
|
|
365
|
+
def update_file(bucket_id:, file_id:, read: nil, write: nil)
|
|
366
|
+
if bucket_id.nil?
|
|
367
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
368
|
+
end
|
|
369
|
+
|
|
118
370
|
if file_id.nil?
|
|
119
371
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
120
372
|
end
|
|
121
373
|
|
|
122
|
-
path = '/storage/files/{fileId}
|
|
374
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
|
375
|
+
.gsub('{bucketId}', bucket_id)
|
|
123
376
|
.gsub('{fileId}', file_id)
|
|
124
377
|
|
|
125
|
-
params = {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
378
|
+
params = {
|
|
379
|
+
read: read,
|
|
380
|
+
write: write,
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
headers = {
|
|
384
|
+
"content-type": 'application/json',
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@client.call(
|
|
388
|
+
method: 'PUT',
|
|
389
|
+
path: path,
|
|
390
|
+
headers: headers,
|
|
391
|
+
params: params,
|
|
392
|
+
response_type: Models::File
|
|
393
|
+
)
|
|
130
394
|
end
|
|
131
395
|
|
|
132
|
-
|
|
396
|
+
# Delete a file by its unique ID. Only users with write permissions have
|
|
397
|
+
# access to delete this resource.
|
|
398
|
+
#
|
|
399
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
400
|
+
# @param [string] file_id File ID.
|
|
401
|
+
#
|
|
402
|
+
# @return []
|
|
403
|
+
def delete_file(bucket_id:, file_id:)
|
|
404
|
+
if bucket_id.nil?
|
|
405
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
406
|
+
end
|
|
407
|
+
|
|
133
408
|
if file_id.nil?
|
|
134
409
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
135
410
|
end
|
|
136
411
|
|
|
137
|
-
path = '/storage/files/{fileId}
|
|
412
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
|
413
|
+
.gsub('{bucketId}', bucket_id)
|
|
138
414
|
.gsub('{fileId}', file_id)
|
|
139
415
|
|
|
140
|
-
params = {
|
|
416
|
+
params = {
|
|
417
|
+
}
|
|
141
418
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
419
|
+
headers = {
|
|
420
|
+
"content-type": 'application/json',
|
|
421
|
+
}
|
|
145
422
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
423
|
+
@client.call(
|
|
424
|
+
method: 'DELETE',
|
|
425
|
+
path: path,
|
|
426
|
+
headers: headers,
|
|
427
|
+
params: params,
|
|
428
|
+
)
|
|
429
|
+
end
|
|
149
430
|
|
|
150
|
-
|
|
151
|
-
|
|
431
|
+
# Get a file content by its unique ID. The endpoint response return with a
|
|
432
|
+
# 'Content-Disposition: attachment' header that tells the browser to start
|
|
433
|
+
# downloading the file to user downloads directory.
|
|
434
|
+
#
|
|
435
|
+
# @param [string] bucket_id Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
436
|
+
# @param [string] file_id File ID.
|
|
437
|
+
#
|
|
438
|
+
# @return []
|
|
439
|
+
def get_file_download(bucket_id:, file_id:)
|
|
440
|
+
if bucket_id.nil?
|
|
441
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
152
442
|
end
|
|
153
443
|
|
|
154
|
-
if
|
|
155
|
-
|
|
444
|
+
if file_id.nil?
|
|
445
|
+
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
156
446
|
end
|
|
157
447
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
448
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}/download'
|
|
449
|
+
.gsub('{bucketId}', bucket_id)
|
|
450
|
+
.gsub('{fileId}', file_id)
|
|
161
451
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
end
|
|
452
|
+
params = {
|
|
453
|
+
}
|
|
165
454
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
455
|
+
headers = {
|
|
456
|
+
"content-type": 'application/json',
|
|
457
|
+
}
|
|
169
458
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
459
|
+
@client.call(
|
|
460
|
+
method: 'GET',
|
|
461
|
+
path: path,
|
|
462
|
+
headers: headers,
|
|
463
|
+
params: params,
|
|
464
|
+
)
|
|
465
|
+
end
|
|
173
466
|
|
|
174
|
-
|
|
175
|
-
|
|
467
|
+
# Get a file preview image. Currently, this method supports preview for image
|
|
468
|
+
# files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
469
|
+
# and spreadsheets, will return the file icon image. You can also pass query
|
|
470
|
+
# string arguments for cutting and resizing your preview image. Preview is
|
|
471
|
+
# supported only for image files smaller than 10MB.
|
|
472
|
+
#
|
|
473
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
474
|
+
# @param [string] file_id File ID
|
|
475
|
+
# @param [number] width Resize preview image width, Pass an integer between 0 to 4000.
|
|
476
|
+
# @param [number] height Resize preview image height, Pass an integer between 0 to 4000.
|
|
477
|
+
# @param [string] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
|
478
|
+
# @param [number] quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
479
|
+
# @param [number] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
|
|
480
|
+
# @param [string] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
|
481
|
+
# @param [number] border_radius Preview image border radius in pixels. Pass an integer between 0 to 4000.
|
|
482
|
+
# @param [number] opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
|
483
|
+
# @param [number] rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
|
|
484
|
+
# @param [string] background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
|
485
|
+
# @param [string] output Output format type (jpeg, jpg, png, gif and webp).
|
|
486
|
+
#
|
|
487
|
+
# @return []
|
|
488
|
+
def get_file_preview(bucket_id:, file_id:, width: nil, height: nil, gravity: nil, quality: nil, border_width: nil, border_color: nil, border_radius: nil, opacity: nil, rotation: nil, background: nil, output: nil)
|
|
489
|
+
if bucket_id.nil?
|
|
490
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
176
491
|
end
|
|
177
492
|
|
|
178
|
-
if
|
|
179
|
-
|
|
493
|
+
if file_id.nil?
|
|
494
|
+
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
180
495
|
end
|
|
181
496
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
497
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}/preview'
|
|
498
|
+
.gsub('{bucketId}', bucket_id)
|
|
499
|
+
.gsub('{fileId}', file_id)
|
|
185
500
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
501
|
+
params = {
|
|
502
|
+
width: width,
|
|
503
|
+
height: height,
|
|
504
|
+
gravity: gravity,
|
|
505
|
+
quality: quality,
|
|
506
|
+
borderWidth: border_width,
|
|
507
|
+
borderColor: border_color,
|
|
508
|
+
borderRadius: border_radius,
|
|
509
|
+
opacity: opacity,
|
|
510
|
+
rotation: rotation,
|
|
511
|
+
background: background,
|
|
512
|
+
output: output,
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
headers = {
|
|
516
|
+
"content-type": 'application/json',
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
@client.call(
|
|
520
|
+
method: 'GET',
|
|
521
|
+
path: path,
|
|
522
|
+
headers: headers,
|
|
523
|
+
params: params,
|
|
524
|
+
)
|
|
189
525
|
end
|
|
190
526
|
|
|
191
|
-
|
|
527
|
+
# Get a file content by its unique ID. This endpoint is similar to the
|
|
528
|
+
# download method but returns with no 'Content-Disposition: attachment'
|
|
529
|
+
# header.
|
|
530
|
+
#
|
|
531
|
+
# @param [string] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
|
532
|
+
# @param [string] file_id File ID.
|
|
533
|
+
#
|
|
534
|
+
# @return []
|
|
535
|
+
def get_file_view(bucket_id:, file_id:)
|
|
536
|
+
if bucket_id.nil?
|
|
537
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
|
538
|
+
end
|
|
539
|
+
|
|
192
540
|
if file_id.nil?
|
|
193
541
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
|
194
542
|
end
|
|
195
543
|
|
|
196
|
-
path = '/storage/files/{fileId}/view'
|
|
544
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}/view'
|
|
545
|
+
.gsub('{bucketId}', bucket_id)
|
|
197
546
|
.gsub('{fileId}', file_id)
|
|
198
547
|
|
|
199
|
-
params = {
|
|
200
|
-
|
|
201
|
-
return @client.call('get', path, {
|
|
202
|
-
'content-type' => 'application/json',
|
|
203
|
-
}, params);
|
|
204
|
-
end
|
|
548
|
+
params = {
|
|
549
|
+
}
|
|
205
550
|
|
|
551
|
+
headers = {
|
|
552
|
+
"content-type": 'application/json',
|
|
553
|
+
}
|
|
206
554
|
|
|
207
|
-
|
|
555
|
+
@client.call(
|
|
556
|
+
method: 'GET',
|
|
557
|
+
path: path,
|
|
558
|
+
headers: headers,
|
|
559
|
+
params: params,
|
|
560
|
+
)
|
|
561
|
+
end
|
|
208
562
|
|
|
209
|
-
private
|
|
210
563
|
end
|
|
211
564
|
end
|