appwrite 4.1.0 → 7.0.0.pre.RC1
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 +32 -11
- data/lib/appwrite/id.rb +11 -0
- data/lib/appwrite/input_file.rb +33 -0
- data/lib/appwrite/models/account.rb +82 -0
- data/lib/appwrite/models/algo_argon2.rb +37 -0
- data/lib/appwrite/models/algo_bcrypt.rb +22 -0
- data/lib/appwrite/models/algo_md5.rb +22 -0
- data/lib/appwrite/models/algo_phpass.rb +22 -0
- data/lib/appwrite/models/algo_scrypt.rb +42 -0
- data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
- data/lib/appwrite/models/algo_sha.rb +22 -0
- data/lib/appwrite/models/attribute_datetime.rb +57 -0
- data/lib/appwrite/models/bucket.rb +25 -25
- data/lib/appwrite/models/collection.rb +25 -15
- data/lib/appwrite/models/database.rb +42 -0
- data/lib/appwrite/models/database_list.rb +32 -0
- data/lib/appwrite/models/deployment.rb +10 -5
- data/lib/appwrite/models/document.rb +15 -10
- data/lib/appwrite/models/execution.rb +20 -10
- data/lib/appwrite/models/file.rb +15 -15
- data/lib/appwrite/models/function.rb +12 -12
- data/lib/appwrite/models/index.rb +1 -1
- data/lib/appwrite/models/membership.rb +25 -10
- data/lib/appwrite/models/session.rb +5 -0
- data/lib/appwrite/models/team.rb +10 -5
- data/lib/appwrite/models/token.rb +5 -0
- data/lib/appwrite/models/user.rb +35 -0
- data/lib/appwrite/models/variable.rb +52 -0
- data/lib/appwrite/models/variable_list.rb +32 -0
- data/lib/appwrite/permission.rb +21 -0
- data/lib/appwrite/query.rb +43 -14
- data/lib/appwrite/role.rb +31 -0
- data/lib/appwrite/services/account.rb +274 -126
- data/lib/appwrite/services/avatars.rb +106 -59
- data/lib/appwrite/services/databases.rb +1425 -0
- data/lib/appwrite/services/functions.rb +381 -176
- data/lib/appwrite/services/health.rb +34 -34
- data/lib/appwrite/services/locale.rb +25 -7
- data/lib/appwrite/services/storage.rb +195 -193
- data/lib/appwrite/services/teams.rb +138 -128
- data/lib/appwrite/services/users.rb +637 -123
- data/lib/appwrite.rb +19 -2
- metadata +22 -6
- data/lib/appwrite/file.rb +0 -17
- data/lib/appwrite/services/database.rb +0 -1049
@@ -3,29 +3,26 @@
|
|
3
3
|
module Appwrite
|
4
4
|
class Storage < Service
|
5
5
|
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
6
10
|
# Get a list of all the storage buckets. You can use the query params to
|
7
11
|
# filter your results.
|
8
12
|
#
|
9
|
-
# @param [
|
10
|
-
# @param [
|
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.
|
13
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus
|
14
|
+
# @param [String] search Search term to filter your list results. Max length: 256 chars.
|
15
15
|
#
|
16
16
|
# @return [BucketList]
|
17
|
-
def list_buckets(
|
17
|
+
def list_buckets(queries: nil, search: nil)
|
18
|
+
|
18
19
|
path = '/storage/buckets'
|
19
20
|
|
20
21
|
params = {
|
22
|
+
queries: queries,
|
21
23
|
search: search,
|
22
|
-
limit: limit,
|
23
|
-
offset: offset,
|
24
|
-
cursor: cursor,
|
25
|
-
cursorDirection: cursor_direction,
|
26
|
-
orderType: order_type,
|
27
24
|
}
|
28
|
-
|
25
|
+
|
29
26
|
headers = {
|
30
27
|
"content-type": 'application/json',
|
31
28
|
}
|
@@ -39,51 +36,49 @@ module Appwrite
|
|
39
36
|
)
|
40
37
|
end
|
41
38
|
|
39
|
+
|
42
40
|
# Create a new storage bucket.
|
43
41
|
#
|
44
|
-
# @param [
|
45
|
-
# @param [
|
46
|
-
# @param [
|
47
|
-
# @param [
|
48
|
-
# @param [
|
49
|
-
# @param [
|
50
|
-
# @param [
|
51
|
-
# @param [
|
52
|
-
# @param [
|
53
|
-
# @param [
|
42
|
+
# @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.
|
43
|
+
# @param [String] name Bucket name
|
44
|
+
# @param [Array] permissions An array of permission strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).
|
45
|
+
# @param [] file_security Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).
|
46
|
+
# @param [] enabled Is bucket enabled?
|
47
|
+
# @param [Integer] 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)
|
48
|
+
# @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
|
49
|
+
# @param [String] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled
|
50
|
+
# @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
51
|
+
# @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
54
52
|
#
|
55
53
|
# @return [Bucket]
|
56
|
-
def create_bucket(bucket_id:, name:,
|
57
|
-
if bucket_id.nil?
|
58
|
-
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
59
|
-
end
|
60
|
-
|
61
|
-
if name.nil?
|
62
|
-
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
63
|
-
end
|
64
|
-
|
65
|
-
if permission.nil?
|
66
|
-
raise Appwrite::Exception.new('Missing required parameter: "permission"')
|
67
|
-
end
|
54
|
+
def create_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, compression: nil, encryption: nil, antivirus: nil)
|
68
55
|
|
69
56
|
path = '/storage/buckets'
|
70
57
|
|
71
58
|
params = {
|
72
59
|
bucketId: bucket_id,
|
73
60
|
name: name,
|
74
|
-
|
75
|
-
|
76
|
-
write: write,
|
61
|
+
permissions: permissions,
|
62
|
+
fileSecurity: file_security,
|
77
63
|
enabled: enabled,
|
78
64
|
maximumFileSize: maximum_file_size,
|
79
65
|
allowedFileExtensions: allowed_file_extensions,
|
66
|
+
compression: compression,
|
80
67
|
encryption: encryption,
|
81
68
|
antivirus: antivirus,
|
82
69
|
}
|
83
|
-
|
70
|
+
|
84
71
|
headers = {
|
85
72
|
"content-type": 'application/json',
|
86
73
|
}
|
74
|
+
if bucket_id.nil?
|
75
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
76
|
+
end
|
77
|
+
|
78
|
+
if name.nil?
|
79
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
80
|
+
end
|
81
|
+
|
87
82
|
|
88
83
|
@client.call(
|
89
84
|
method: 'POST',
|
@@ -94,26 +89,28 @@ module Appwrite
|
|
94
89
|
)
|
95
90
|
end
|
96
91
|
|
92
|
+
|
97
93
|
# Get a storage bucket by its unique ID. This endpoint response returns a
|
98
94
|
# JSON object with the storage bucket metadata.
|
99
95
|
#
|
100
|
-
# @param [
|
96
|
+
# @param [String] bucket_id Bucket unique ID.
|
101
97
|
#
|
102
98
|
# @return [Bucket]
|
103
99
|
def get_bucket(bucket_id:)
|
104
|
-
if bucket_id.nil?
|
105
|
-
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
106
|
-
end
|
107
100
|
|
108
101
|
path = '/storage/buckets/{bucketId}'
|
109
|
-
.gsub('{bucketId}', bucket_id)
|
110
102
|
|
111
103
|
params = {
|
112
104
|
}
|
113
|
-
|
105
|
+
|
114
106
|
headers = {
|
115
107
|
"content-type": 'application/json',
|
116
108
|
}
|
109
|
+
if bucket_id.nil?
|
110
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
111
|
+
end
|
112
|
+
|
113
|
+
.gsub('{bucketId}', bucket_id)
|
117
114
|
|
118
115
|
@client.call(
|
119
116
|
method: 'GET',
|
@@ -124,51 +121,49 @@ module Appwrite
|
|
124
121
|
)
|
125
122
|
end
|
126
123
|
|
124
|
+
|
127
125
|
# Update a storage bucket by its unique ID.
|
128
126
|
#
|
129
|
-
# @param [
|
130
|
-
# @param [
|
131
|
-
# @param [
|
132
|
-
# @param [
|
133
|
-
# @param [
|
134
|
-
# @param [
|
135
|
-
# @param [
|
136
|
-
# @param [
|
137
|
-
# @param [
|
138
|
-
# @param [
|
127
|
+
# @param [String] bucket_id Bucket unique ID.
|
128
|
+
# @param [String] name Bucket name
|
129
|
+
# @param [Array] permissions An array of permission strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
|
130
|
+
# @param [] file_security Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).
|
131
|
+
# @param [] enabled Is bucket enabled?
|
132
|
+
# @param [Integer] 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)
|
133
|
+
# @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
|
134
|
+
# @param [String] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled
|
135
|
+
# @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
|
136
|
+
# @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
|
139
137
|
#
|
140
138
|
# @return [Bucket]
|
141
|
-
def update_bucket(bucket_id:, name:,
|
142
|
-
if bucket_id.nil?
|
143
|
-
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
144
|
-
end
|
145
|
-
|
146
|
-
if name.nil?
|
147
|
-
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
148
|
-
end
|
149
|
-
|
150
|
-
if permission.nil?
|
151
|
-
raise Appwrite::Exception.new('Missing required parameter: "permission"')
|
152
|
-
end
|
139
|
+
def update_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabled: nil, maximum_file_size: nil, allowed_file_extensions: nil, compression: nil, encryption: nil, antivirus: nil)
|
153
140
|
|
154
141
|
path = '/storage/buckets/{bucketId}'
|
155
|
-
.gsub('{bucketId}', bucket_id)
|
156
142
|
|
157
143
|
params = {
|
158
144
|
name: name,
|
159
|
-
|
160
|
-
|
161
|
-
write: write,
|
145
|
+
permissions: permissions,
|
146
|
+
fileSecurity: file_security,
|
162
147
|
enabled: enabled,
|
163
148
|
maximumFileSize: maximum_file_size,
|
164
149
|
allowedFileExtensions: allowed_file_extensions,
|
150
|
+
compression: compression,
|
165
151
|
encryption: encryption,
|
166
152
|
antivirus: antivirus,
|
167
153
|
}
|
168
|
-
|
154
|
+
|
169
155
|
headers = {
|
170
156
|
"content-type": 'application/json',
|
171
157
|
}
|
158
|
+
if bucket_id.nil?
|
159
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
160
|
+
end
|
161
|
+
|
162
|
+
if name.nil?
|
163
|
+
raise Appwrite::Exception.new('Missing required parameter: "name"')
|
164
|
+
end
|
165
|
+
|
166
|
+
.gsub('{bucketId}', bucket_id)
|
172
167
|
|
173
168
|
@client.call(
|
174
169
|
method: 'PUT',
|
@@ -179,25 +174,27 @@ module Appwrite
|
|
179
174
|
)
|
180
175
|
end
|
181
176
|
|
177
|
+
|
182
178
|
# Delete a storage bucket by its unique ID.
|
183
179
|
#
|
184
|
-
# @param [
|
180
|
+
# @param [String] bucket_id Bucket unique ID.
|
185
181
|
#
|
186
182
|
# @return []
|
187
183
|
def delete_bucket(bucket_id:)
|
188
|
-
if bucket_id.nil?
|
189
|
-
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
190
|
-
end
|
191
184
|
|
192
185
|
path = '/storage/buckets/{bucketId}'
|
193
|
-
.gsub('{bucketId}', bucket_id)
|
194
186
|
|
195
187
|
params = {
|
196
188
|
}
|
197
|
-
|
189
|
+
|
198
190
|
headers = {
|
199
191
|
"content-type": 'application/json',
|
200
192
|
}
|
193
|
+
if bucket_id.nil?
|
194
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
195
|
+
end
|
196
|
+
|
197
|
+
.gsub('{bucketId}', bucket_id)
|
201
198
|
|
202
199
|
@client.call(
|
203
200
|
method: 'DELETE',
|
@@ -207,39 +204,33 @@ module Appwrite
|
|
207
204
|
)
|
208
205
|
end
|
209
206
|
|
207
|
+
|
210
208
|
# Get a list of all the user files. You can use the query params to filter
|
211
209
|
# your results. On admin mode, this endpoint will return a list of all of the
|
212
210
|
# project's files. [Learn more about different API modes](/docs/admin).
|
213
211
|
#
|
214
|
-
# @param [
|
215
|
-
# @param [
|
216
|
-
# @param [
|
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.
|
212
|
+
# @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).
|
213
|
+
# @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
|
214
|
+
# @param [String] search Search term to filter your list results. Max length: 256 chars.
|
221
215
|
#
|
222
216
|
# @return [FileList]
|
223
|
-
def list_files(bucket_id:,
|
224
|
-
if bucket_id.nil?
|
225
|
-
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
226
|
-
end
|
217
|
+
def list_files(bucket_id:, queries: nil, search: nil)
|
227
218
|
|
228
219
|
path = '/storage/buckets/{bucketId}/files'
|
229
|
-
.gsub('{bucketId}', bucket_id)
|
230
220
|
|
231
221
|
params = {
|
222
|
+
queries: queries,
|
232
223
|
search: search,
|
233
|
-
limit: limit,
|
234
|
-
offset: offset,
|
235
|
-
cursor: cursor,
|
236
|
-
cursorDirection: cursor_direction,
|
237
|
-
orderType: order_type,
|
238
224
|
}
|
239
|
-
|
225
|
+
|
240
226
|
headers = {
|
241
227
|
"content-type": 'application/json',
|
242
228
|
}
|
229
|
+
if bucket_id.nil?
|
230
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
231
|
+
end
|
232
|
+
|
233
|
+
.gsub('{bucketId}', bucket_id)
|
243
234
|
|
244
235
|
@client.call(
|
245
236
|
method: 'GET',
|
@@ -250,10 +241,11 @@ module Appwrite
|
|
250
241
|
)
|
251
242
|
end
|
252
243
|
|
244
|
+
|
253
245
|
# Create a new file. Before using this route, you should create a new bucket
|
254
246
|
# resource using either a [server
|
255
|
-
# integration](/docs/server/
|
256
|
-
#
|
247
|
+
# integration](/docs/server/storage#storageCreateBucket) API or directly from
|
248
|
+
# your Appwrite console.
|
257
249
|
#
|
258
250
|
# Larger files should be uploaded using multiple requests with the
|
259
251
|
# [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
|
@@ -269,14 +261,25 @@ module Appwrite
|
|
269
261
|
# chunking logic will be managed by the SDK internally.
|
270
262
|
#
|
271
263
|
#
|
272
|
-
# @param [
|
273
|
-
# @param [
|
264
|
+
# @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).
|
265
|
+
# @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
266
|
# @param [file] file Binary file.
|
275
|
-
# @param [
|
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.
|
267
|
+
# @param [Array] permissions An array of permission strings. By default the current user is granted with all permissions. [Learn more about permissions](/docs/permissions).
|
277
268
|
#
|
278
269
|
# @return [File]
|
279
|
-
def create_file(bucket_id:, file_id:, file:,
|
270
|
+
def create_file(bucket_id:, file_id:, file:, permissions: nil, on_progress: nil)
|
271
|
+
|
272
|
+
path = '/storage/buckets/{bucketId}/files'
|
273
|
+
|
274
|
+
params = {
|
275
|
+
fileId: file_id,
|
276
|
+
file: file,
|
277
|
+
permissions: permissions,
|
278
|
+
}
|
279
|
+
|
280
|
+
headers = {
|
281
|
+
"content-type": 'multipart/form-data',
|
282
|
+
}
|
280
283
|
if bucket_id.nil?
|
281
284
|
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
282
285
|
end
|
@@ -289,20 +292,8 @@ module Appwrite
|
|
289
292
|
raise Appwrite::Exception.new('Missing required parameter: "file"')
|
290
293
|
end
|
291
294
|
|
292
|
-
path = '/storage/buckets/{bucketId}/files'
|
293
295
|
.gsub('{bucketId}', bucket_id)
|
294
296
|
|
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
297
|
id_param_name = "fileId"
|
307
298
|
param_name = 'file'
|
308
299
|
|
@@ -317,14 +308,24 @@ module Appwrite
|
|
317
308
|
)
|
318
309
|
end
|
319
310
|
|
311
|
+
|
320
312
|
# Get a file by its unique ID. This endpoint response returns a JSON object
|
321
313
|
# with the file metadata.
|
322
314
|
#
|
323
|
-
# @param [
|
324
|
-
# @param [
|
315
|
+
# @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).
|
316
|
+
# @param [String] file_id File ID.
|
325
317
|
#
|
326
318
|
# @return [File]
|
327
319
|
def get_file(bucket_id:, file_id:)
|
320
|
+
|
321
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
322
|
+
|
323
|
+
params = {
|
324
|
+
}
|
325
|
+
|
326
|
+
headers = {
|
327
|
+
"content-type": 'application/json',
|
328
|
+
}
|
328
329
|
if bucket_id.nil?
|
329
330
|
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
330
331
|
end
|
@@ -333,17 +334,9 @@ module Appwrite
|
|
333
334
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
334
335
|
end
|
335
336
|
|
336
|
-
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
337
337
|
.gsub('{bucketId}', bucket_id)
|
338
338
|
.gsub('{fileId}', file_id)
|
339
339
|
|
340
|
-
params = {
|
341
|
-
}
|
342
|
-
|
343
|
-
headers = {
|
344
|
-
"content-type": 'application/json',
|
345
|
-
}
|
346
|
-
|
347
340
|
@client.call(
|
348
341
|
method: 'GET',
|
349
342
|
path: path,
|
@@ -353,16 +346,26 @@ module Appwrite
|
|
353
346
|
)
|
354
347
|
end
|
355
348
|
|
349
|
+
|
356
350
|
# Update a file by its unique ID. Only users with write permissions have
|
357
351
|
# access to update this resource.
|
358
352
|
#
|
359
|
-
# @param [
|
360
|
-
# @param [
|
361
|
-
# @param [
|
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.
|
353
|
+
# @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).
|
354
|
+
# @param [String] file_id File unique ID.
|
355
|
+
# @param [Array] permissions An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).
|
363
356
|
#
|
364
357
|
# @return [File]
|
365
|
-
def update_file(bucket_id:, file_id:,
|
358
|
+
def update_file(bucket_id:, file_id:, permissions: nil)
|
359
|
+
|
360
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
361
|
+
|
362
|
+
params = {
|
363
|
+
permissions: permissions,
|
364
|
+
}
|
365
|
+
|
366
|
+
headers = {
|
367
|
+
"content-type": 'application/json',
|
368
|
+
}
|
366
369
|
if bucket_id.nil?
|
367
370
|
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
368
371
|
end
|
@@ -371,19 +374,9 @@ module Appwrite
|
|
371
374
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
372
375
|
end
|
373
376
|
|
374
|
-
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
375
377
|
.gsub('{bucketId}', bucket_id)
|
376
378
|
.gsub('{fileId}', file_id)
|
377
379
|
|
378
|
-
params = {
|
379
|
-
read: read,
|
380
|
-
write: write,
|
381
|
-
}
|
382
|
-
|
383
|
-
headers = {
|
384
|
-
"content-type": 'application/json',
|
385
|
-
}
|
386
|
-
|
387
380
|
@client.call(
|
388
381
|
method: 'PUT',
|
389
382
|
path: path,
|
@@ -393,14 +386,24 @@ module Appwrite
|
|
393
386
|
)
|
394
387
|
end
|
395
388
|
|
389
|
+
|
396
390
|
# Delete a file by its unique ID. Only users with write permissions have
|
397
391
|
# access to delete this resource.
|
398
392
|
#
|
399
|
-
# @param [
|
400
|
-
# @param [
|
393
|
+
# @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).
|
394
|
+
# @param [String] file_id File ID.
|
401
395
|
#
|
402
396
|
# @return []
|
403
397
|
def delete_file(bucket_id:, file_id:)
|
398
|
+
|
399
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
400
|
+
|
401
|
+
params = {
|
402
|
+
}
|
403
|
+
|
404
|
+
headers = {
|
405
|
+
"content-type": 'application/json',
|
406
|
+
}
|
404
407
|
if bucket_id.nil?
|
405
408
|
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
406
409
|
end
|
@@ -409,17 +412,9 @@ module Appwrite
|
|
409
412
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
410
413
|
end
|
411
414
|
|
412
|
-
path = '/storage/buckets/{bucketId}/files/{fileId}'
|
413
415
|
.gsub('{bucketId}', bucket_id)
|
414
416
|
.gsub('{fileId}', file_id)
|
415
417
|
|
416
|
-
params = {
|
417
|
-
}
|
418
|
-
|
419
|
-
headers = {
|
420
|
-
"content-type": 'application/json',
|
421
|
-
}
|
422
|
-
|
423
418
|
@client.call(
|
424
419
|
method: 'DELETE',
|
425
420
|
path: path,
|
@@ -428,15 +423,25 @@ module Appwrite
|
|
428
423
|
)
|
429
424
|
end
|
430
425
|
|
426
|
+
|
431
427
|
# Get a file content by its unique ID. The endpoint response return with a
|
432
428
|
# 'Content-Disposition: attachment' header that tells the browser to start
|
433
429
|
# downloading the file to user downloads directory.
|
434
430
|
#
|
435
|
-
# @param [
|
436
|
-
# @param [
|
431
|
+
# @param [String] bucket_id Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
432
|
+
# @param [String] file_id File ID.
|
437
433
|
#
|
438
434
|
# @return []
|
439
435
|
def get_file_download(bucket_id:, file_id:)
|
436
|
+
|
437
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}/download'
|
438
|
+
|
439
|
+
params = {
|
440
|
+
}
|
441
|
+
|
442
|
+
headers = {
|
443
|
+
"content-type": 'application/json',
|
444
|
+
}
|
440
445
|
if bucket_id.nil?
|
441
446
|
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
442
447
|
end
|
@@ -445,17 +450,9 @@ module Appwrite
|
|
445
450
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
446
451
|
end
|
447
452
|
|
448
|
-
path = '/storage/buckets/{bucketId}/files/{fileId}/download'
|
449
453
|
.gsub('{bucketId}', bucket_id)
|
450
454
|
.gsub('{fileId}', file_id)
|
451
455
|
|
452
|
-
params = {
|
453
|
-
}
|
454
|
-
|
455
|
-
headers = {
|
456
|
-
"content-type": 'application/json',
|
457
|
-
}
|
458
|
-
|
459
456
|
@client.call(
|
460
457
|
method: 'GET',
|
461
458
|
path: path,
|
@@ -464,39 +461,31 @@ module Appwrite
|
|
464
461
|
)
|
465
462
|
end
|
466
463
|
|
464
|
+
|
467
465
|
# Get a file preview image. Currently, this method supports preview for image
|
468
466
|
# files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
469
467
|
# and spreadsheets, will return the file icon image. You can also pass query
|
470
468
|
# string arguments for cutting and resizing your preview image. Preview is
|
471
469
|
# supported only for image files smaller than 10MB.
|
472
470
|
#
|
473
|
-
# @param [
|
474
|
-
# @param [
|
475
|
-
# @param [
|
476
|
-
# @param [
|
477
|
-
# @param [
|
478
|
-
# @param [
|
479
|
-
# @param [
|
480
|
-
# @param [
|
481
|
-
# @param [
|
482
|
-
# @param [
|
483
|
-
# @param [
|
484
|
-
# @param [
|
485
|
-
# @param [
|
471
|
+
# @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).
|
472
|
+
# @param [String] file_id File ID
|
473
|
+
# @param [Integer] width Resize preview image width, Pass an integer between 0 to 4000.
|
474
|
+
# @param [Integer] height Resize preview image height, Pass an integer between 0 to 4000.
|
475
|
+
# @param [String] gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
476
|
+
# @param [Integer] quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
|
477
|
+
# @param [Integer] border_width Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
|
478
|
+
# @param [String] border_color Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
479
|
+
# @param [Integer] border_radius Preview image border radius in pixels. Pass an integer between 0 to 4000.
|
480
|
+
# @param [Float] opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
481
|
+
# @param [Integer] rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
|
482
|
+
# @param [String] background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
483
|
+
# @param [String] output Output format type (jpeg, jpg, png, gif and webp).
|
486
484
|
#
|
487
485
|
# @return []
|
488
486
|
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"')
|
491
|
-
end
|
492
|
-
|
493
|
-
if file_id.nil?
|
494
|
-
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
495
|
-
end
|
496
487
|
|
497
488
|
path = '/storage/buckets/{bucketId}/files/{fileId}/preview'
|
498
|
-
.gsub('{bucketId}', bucket_id)
|
499
|
-
.gsub('{fileId}', file_id)
|
500
489
|
|
501
490
|
params = {
|
502
491
|
width: width,
|
@@ -511,10 +500,20 @@ module Appwrite
|
|
511
500
|
background: background,
|
512
501
|
output: output,
|
513
502
|
}
|
514
|
-
|
503
|
+
|
515
504
|
headers = {
|
516
505
|
"content-type": 'application/json',
|
517
506
|
}
|
507
|
+
if bucket_id.nil?
|
508
|
+
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
509
|
+
end
|
510
|
+
|
511
|
+
if file_id.nil?
|
512
|
+
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
513
|
+
end
|
514
|
+
|
515
|
+
.gsub('{bucketId}', bucket_id)
|
516
|
+
.gsub('{fileId}', file_id)
|
518
517
|
|
519
518
|
@client.call(
|
520
519
|
method: 'GET',
|
@@ -524,15 +523,25 @@ module Appwrite
|
|
524
523
|
)
|
525
524
|
end
|
526
525
|
|
526
|
+
|
527
527
|
# Get a file content by its unique ID. This endpoint is similar to the
|
528
528
|
# download method but returns with no 'Content-Disposition: attachment'
|
529
529
|
# header.
|
530
530
|
#
|
531
|
-
# @param [
|
532
|
-
# @param [
|
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
533
|
#
|
534
534
|
# @return []
|
535
535
|
def get_file_view(bucket_id:, file_id:)
|
536
|
+
|
537
|
+
path = '/storage/buckets/{bucketId}/files/{fileId}/view'
|
538
|
+
|
539
|
+
params = {
|
540
|
+
}
|
541
|
+
|
542
|
+
headers = {
|
543
|
+
"content-type": 'application/json',
|
544
|
+
}
|
536
545
|
if bucket_id.nil?
|
537
546
|
raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
|
538
547
|
end
|
@@ -541,17 +550,9 @@ module Appwrite
|
|
541
550
|
raise Appwrite::Exception.new('Missing required parameter: "fileId"')
|
542
551
|
end
|
543
552
|
|
544
|
-
path = '/storage/buckets/{bucketId}/files/{fileId}/view'
|
545
553
|
.gsub('{bucketId}', bucket_id)
|
546
554
|
.gsub('{fileId}', file_id)
|
547
555
|
|
548
|
-
params = {
|
549
|
-
}
|
550
|
-
|
551
|
-
headers = {
|
552
|
-
"content-type": 'application/json',
|
553
|
-
}
|
554
|
-
|
555
556
|
@client.call(
|
556
557
|
method: 'GET',
|
557
558
|
path: path,
|
@@ -560,5 +561,6 @@ module Appwrite
|
|
560
561
|
)
|
561
562
|
end
|
562
563
|
|
564
|
+
|
563
565
|
end
|
564
566
|
end
|