@appwrite.io/console 0.2.0 → 0.4.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.
- package/README.md +3 -3
- package/dist/cjs/sdk.js +3353 -1497
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +3350 -1498
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +3353 -1497
- package/docs/examples/account/create-anonymous-session.md +1 -1
- package/docs/examples/account/create-email-session.md +1 -1
- package/docs/examples/account/create-j-w-t.md +1 -1
- package/docs/examples/account/create-magic-u-r-l-session.md +1 -1
- package/docs/examples/account/create-o-auth2session.md +1 -1
- package/docs/examples/account/create-phone-session.md +1 -1
- package/docs/examples/account/create-phone-verification.md +1 -1
- package/docs/examples/account/create-recovery.md +1 -1
- package/docs/examples/account/create-verification.md +1 -1
- package/docs/examples/account/create.md +1 -1
- package/docs/examples/account/{create-with-invite-code.md → delete-identity.md} +2 -2
- package/docs/examples/account/delete-session.md +1 -1
- package/docs/examples/account/delete-sessions.md +1 -1
- package/docs/examples/account/get-prefs.md +1 -1
- package/docs/examples/account/get-session.md +1 -1
- package/docs/examples/account/get.md +1 -1
- package/docs/examples/account/list-identities.md +18 -0
- package/docs/examples/account/list-logs.md +1 -1
- package/docs/examples/account/list-sessions.md +1 -1
- package/docs/examples/account/update-email.md +1 -1
- package/docs/examples/account/update-magic-u-r-l-session.md +1 -1
- package/docs/examples/account/update-name.md +1 -1
- package/docs/examples/account/update-password.md +1 -1
- package/docs/examples/account/update-phone-session.md +1 -1
- package/docs/examples/account/update-phone-verification.md +1 -1
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/account/update-prefs.md +1 -1
- package/docs/examples/account/update-recovery.md +1 -1
- package/docs/examples/account/update-session.md +1 -1
- package/docs/examples/account/update-status.md +1 -1
- package/docs/examples/account/update-verification.md +1 -1
- package/docs/examples/assistant/chat.md +18 -0
- package/docs/examples/avatars/get-browser.md +1 -1
- package/docs/examples/avatars/get-credit-card.md +1 -1
- package/docs/examples/avatars/get-favicon.md +1 -1
- package/docs/examples/avatars/get-flag.md +1 -1
- package/docs/examples/avatars/get-image.md +1 -1
- package/docs/examples/avatars/get-initials.md +1 -1
- package/docs/examples/avatars/get-q-r.md +1 -1
- package/docs/examples/console/variables.md +1 -1
- package/docs/examples/databases/create-boolean-attribute.md +1 -1
- package/docs/examples/databases/create-collection.md +1 -1
- package/docs/examples/databases/create-datetime-attribute.md +1 -1
- package/docs/examples/databases/create-document.md +1 -1
- package/docs/examples/databases/create-email-attribute.md +1 -1
- package/docs/examples/databases/create-enum-attribute.md +1 -1
- package/docs/examples/databases/create-float-attribute.md +1 -1
- package/docs/examples/databases/create-index.md +1 -1
- package/docs/examples/databases/create-integer-attribute.md +1 -1
- package/docs/examples/databases/create-ip-attribute.md +1 -1
- package/docs/examples/databases/create-relationship-attribute.md +1 -1
- package/docs/examples/databases/create-string-attribute.md +1 -1
- package/docs/examples/databases/create-url-attribute.md +1 -1
- package/docs/examples/databases/create.md +1 -1
- package/docs/examples/databases/delete-attribute.md +1 -1
- package/docs/examples/databases/delete-collection.md +1 -1
- package/docs/examples/databases/delete-document.md +1 -1
- package/docs/examples/databases/delete-index.md +1 -1
- package/docs/examples/databases/delete.md +1 -1
- package/docs/examples/databases/get-attribute.md +1 -1
- package/docs/examples/databases/get-collection-usage.md +1 -1
- package/docs/examples/databases/get-collection.md +1 -1
- package/docs/examples/databases/get-database-usage.md +1 -1
- package/docs/examples/databases/get-document.md +1 -1
- package/docs/examples/databases/get-index.md +1 -1
- package/docs/examples/databases/get-usage.md +1 -1
- package/docs/examples/databases/get.md +1 -1
- package/docs/examples/databases/list-attributes.md +1 -1
- package/docs/examples/databases/list-collection-logs.md +1 -1
- package/docs/examples/databases/list-collections.md +1 -1
- package/docs/examples/databases/list-document-logs.md +1 -1
- package/docs/examples/databases/list-documents.md +1 -1
- package/docs/examples/databases/list-indexes.md +1 -1
- package/docs/examples/databases/list-logs.md +1 -1
- package/docs/examples/databases/list.md +1 -1
- package/docs/examples/databases/update-boolean-attribute.md +1 -1
- package/docs/examples/databases/update-collection.md +1 -1
- package/docs/examples/databases/update-datetime-attribute.md +1 -1
- package/docs/examples/databases/update-document.md +1 -1
- package/docs/examples/databases/update-email-attribute.md +1 -1
- package/docs/examples/databases/update-enum-attribute.md +1 -1
- package/docs/examples/databases/update-float-attribute.md +1 -1
- package/docs/examples/databases/update-integer-attribute.md +1 -1
- package/docs/examples/databases/update-ip-attribute.md +1 -1
- package/docs/examples/databases/update-relationship-attribute.md +1 -1
- package/docs/examples/databases/update-string-attribute.md +1 -1
- package/docs/examples/databases/update-url-attribute.md +1 -1
- package/docs/examples/databases/update.md +1 -1
- package/docs/examples/functions/create-build.md +1 -1
- package/docs/examples/functions/create-deployment.md +2 -2
- package/docs/examples/functions/create-execution.md +1 -1
- package/docs/examples/functions/create-variable.md +1 -1
- package/docs/examples/functions/create.md +2 -2
- package/docs/examples/functions/delete-deployment.md +1 -1
- package/docs/examples/functions/delete-variable.md +1 -1
- package/docs/examples/functions/delete.md +1 -1
- package/docs/examples/functions/download-deployment.md +14 -0
- package/docs/examples/functions/get-deployment.md +1 -1
- package/docs/examples/functions/get-execution.md +1 -1
- package/docs/examples/functions/get-function-usage.md +1 -1
- package/docs/examples/functions/get-usage.md +1 -1
- package/docs/examples/functions/get-variable.md +1 -1
- package/docs/examples/functions/get.md +1 -1
- package/docs/examples/functions/list-deployments.md +1 -1
- package/docs/examples/functions/list-executions.md +1 -1
- package/docs/examples/functions/list-runtimes.md +1 -1
- package/docs/examples/functions/list-variables.md +1 -1
- package/docs/examples/functions/list.md +1 -1
- package/docs/examples/functions/update-deployment.md +1 -1
- package/docs/examples/functions/update-variable.md +1 -1
- package/docs/examples/functions/update.md +1 -1
- package/docs/examples/graphql/mutation.md +1 -1
- package/docs/examples/graphql/query.md +1 -1
- package/docs/examples/health/get-antivirus.md +1 -1
- package/docs/examples/health/get-cache.md +1 -1
- package/docs/examples/health/get-d-b.md +1 -1
- package/docs/examples/health/get-pub-sub.md +1 -1
- package/docs/examples/health/get-queue-builds.md +18 -0
- package/docs/examples/health/get-queue-certificates.md +1 -1
- package/docs/examples/health/get-queue-databases.md +18 -0
- package/docs/examples/health/get-queue-deletes.md +18 -0
- package/docs/examples/health/get-queue-functions.md +1 -1
- package/docs/examples/health/get-queue-logs.md +1 -1
- package/docs/examples/health/get-queue-mails.md +18 -0
- package/docs/examples/health/get-queue-messaging.md +18 -0
- package/docs/examples/health/get-queue-migrations.md +18 -0
- package/docs/examples/health/get-queue-webhooks.md +1 -1
- package/docs/examples/health/get-queue.md +1 -1
- package/docs/examples/health/get-storage-local.md +1 -1
- package/docs/examples/health/get-time.md +1 -1
- package/docs/examples/health/get.md +1 -1
- package/docs/examples/locale/get.md +1 -1
- package/docs/examples/locale/list-codes.md +18 -0
- package/docs/examples/locale/list-continents.md +1 -1
- package/docs/examples/locale/list-countries-e-u.md +1 -1
- package/docs/examples/locale/list-countries-phones.md +1 -1
- package/docs/examples/locale/list-countries.md +1 -1
- package/docs/examples/locale/list-currencies.md +1 -1
- package/docs/examples/locale/list-languages.md +1 -1
- package/docs/examples/migrations/create-appwrite-migration.md +18 -0
- package/docs/examples/migrations/create-firebase-migration.md +18 -0
- package/docs/examples/migrations/create-firebase-o-auth-migration.md +18 -0
- package/docs/examples/migrations/create-n-host-migration.md +18 -0
- package/docs/examples/migrations/create-supabase-migration.md +18 -0
- package/docs/examples/migrations/delete-firebase-auth.md +18 -0
- package/docs/examples/migrations/delete.md +18 -0
- package/docs/examples/migrations/get-appwrite-report.md +18 -0
- package/docs/examples/migrations/get-firebase-report-o-auth.md +18 -0
- package/docs/examples/migrations/get-firebase-report.md +18 -0
- package/docs/examples/migrations/get-n-host-report.md +18 -0
- package/docs/examples/migrations/get-supabase-report.md +18 -0
- package/docs/examples/migrations/get.md +18 -0
- package/docs/examples/migrations/list-firebase-projects.md +18 -0
- package/docs/examples/migrations/list.md +18 -0
- package/docs/examples/migrations/retry.md +18 -0
- package/docs/examples/project/create-variable.md +18 -0
- package/docs/examples/project/delete-variable.md +18 -0
- package/docs/examples/project/get-usage.md +2 -2
- package/docs/examples/project/get-variable.md +18 -0
- package/docs/examples/project/list-variables.md +18 -0
- package/docs/examples/project/update-variable.md +18 -0
- package/docs/examples/projects/create-key.md +1 -1
- package/docs/examples/projects/create-platform.md +1 -1
- package/docs/examples/projects/create-webhook.md +1 -1
- package/docs/examples/projects/create.md +2 -2
- package/docs/examples/projects/delete-email-template.md +18 -0
- package/docs/examples/projects/delete-key.md +1 -1
- package/docs/examples/projects/delete-platform.md +1 -1
- package/docs/examples/projects/delete-sms-template.md +18 -0
- package/docs/examples/projects/delete-webhook.md +1 -1
- package/docs/examples/projects/delete.md +2 -2
- package/docs/examples/projects/get-email-template.md +18 -0
- package/docs/examples/projects/get-key.md +1 -1
- package/docs/examples/projects/get-platform.md +1 -1
- package/docs/examples/projects/get-sms-template.md +18 -0
- package/docs/examples/projects/get-webhook.md +1 -1
- package/docs/examples/projects/get.md +1 -1
- package/docs/examples/projects/list-keys.md +1 -1
- package/docs/examples/projects/list-platforms.md +1 -1
- package/docs/examples/projects/list-webhooks.md +1 -1
- package/docs/examples/projects/list.md +1 -1
- package/docs/examples/projects/update-auth-duration.md +1 -1
- package/docs/examples/projects/update-auth-limit.md +1 -1
- package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
- package/docs/examples/projects/update-auth-password-history.md +1 -1
- package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
- package/docs/examples/projects/update-auth-status.md +1 -1
- package/docs/examples/projects/update-email-template.md +18 -0
- package/docs/examples/projects/update-key.md +1 -1
- package/docs/examples/projects/update-o-auth2.md +1 -1
- package/docs/examples/projects/{delete-domain.md → update-personal-data-check.md} +2 -2
- package/docs/examples/projects/update-platform.md +1 -1
- package/docs/examples/projects/{create-domain.md → update-service-status-all.md} +2 -2
- package/docs/examples/projects/update-service-status.md +1 -1
- package/docs/examples/projects/update-sms-template.md +18 -0
- package/docs/examples/projects/{get-domain.md → update-smtp-configuration.md} +2 -2
- package/docs/examples/projects/{list-domains.md → update-team.md} +2 -2
- package/docs/examples/projects/update-webhook-signature.md +1 -1
- package/docs/examples/projects/update-webhook.md +1 -1
- package/docs/examples/projects/update.md +1 -1
- package/docs/examples/proxy/create-rule.md +18 -0
- package/docs/examples/proxy/delete-rule.md +18 -0
- package/docs/examples/proxy/get-rule.md +18 -0
- package/docs/examples/proxy/list-rules.md +18 -0
- package/docs/examples/proxy/update-rule-verification.md +18 -0
- package/docs/examples/storage/create-bucket.md +1 -1
- package/docs/examples/storage/create-file.md +1 -1
- package/docs/examples/storage/delete-bucket.md +1 -1
- package/docs/examples/storage/delete-file.md +1 -1
- package/docs/examples/storage/get-bucket-usage.md +1 -1
- package/docs/examples/storage/get-bucket.md +1 -1
- package/docs/examples/storage/get-file-download.md +1 -1
- package/docs/examples/storage/get-file-preview.md +1 -1
- package/docs/examples/storage/get-file-view.md +1 -1
- package/docs/examples/storage/get-file.md +1 -1
- package/docs/examples/storage/get-usage.md +1 -1
- package/docs/examples/storage/list-buckets.md +1 -1
- package/docs/examples/storage/list-files.md +1 -1
- package/docs/examples/storage/update-bucket.md +1 -1
- package/docs/examples/storage/update-file.md +1 -1
- package/docs/examples/teams/create-membership.md +2 -2
- package/docs/examples/teams/create.md +1 -1
- package/docs/examples/teams/delete-membership.md +1 -1
- package/docs/examples/teams/delete.md +1 -1
- package/docs/examples/teams/get-membership.md +1 -1
- package/docs/examples/teams/get-prefs.md +1 -1
- package/docs/examples/teams/get.md +1 -1
- package/docs/examples/teams/list-logs.md +1 -1
- package/docs/examples/teams/list-memberships.md +1 -1
- package/docs/examples/teams/list.md +1 -1
- package/docs/examples/teams/update-membership-status.md +1 -1
- package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
- package/docs/examples/teams/update-name.md +1 -1
- package/docs/examples/teams/update-prefs.md +1 -1
- package/docs/examples/users/create-argon2user.md +1 -1
- package/docs/examples/users/create-bcrypt-user.md +1 -1
- package/docs/examples/users/create-m-d5user.md +1 -1
- package/docs/examples/users/create-p-h-pass-user.md +1 -1
- package/docs/examples/users/create-s-h-a-user.md +1 -1
- package/docs/examples/users/create-scrypt-modified-user.md +1 -1
- package/docs/examples/users/create-scrypt-user.md +1 -1
- package/docs/examples/users/create.md +1 -1
- package/docs/examples/users/delete-identity.md +18 -0
- package/docs/examples/users/delete-session.md +1 -1
- package/docs/examples/users/delete-sessions.md +1 -1
- package/docs/examples/users/delete.md +1 -1
- package/docs/examples/users/get-prefs.md +1 -1
- package/docs/examples/users/get-usage.md +1 -1
- package/docs/examples/users/get.md +1 -1
- package/docs/examples/users/list-identities.md +18 -0
- package/docs/examples/users/list-logs.md +1 -1
- package/docs/examples/users/list-memberships.md +1 -1
- package/docs/examples/users/list-sessions.md +1 -1
- package/docs/examples/users/list.md +1 -1
- package/docs/examples/users/update-email-verification.md +1 -1
- package/docs/examples/users/update-email.md +1 -1
- package/docs/examples/users/update-labels.md +18 -0
- package/docs/examples/users/update-name.md +1 -1
- package/docs/examples/users/update-password.md +1 -1
- package/docs/examples/users/update-phone-verification.md +1 -1
- package/docs/examples/users/update-phone.md +1 -1
- package/docs/examples/users/update-prefs.md +1 -1
- package/docs/examples/users/update-status.md +1 -1
- package/docs/examples/vcs/create-repository-detection.md +18 -0
- package/docs/examples/vcs/create-repository.md +18 -0
- package/docs/examples/vcs/delete-installation.md +18 -0
- package/docs/examples/vcs/get-installation.md +18 -0
- package/docs/examples/vcs/get-repository.md +18 -0
- package/docs/examples/vcs/list-installations.md +18 -0
- package/docs/examples/vcs/list-repositories.md +18 -0
- package/docs/examples/vcs/list-repository-branches.md +18 -0
- package/docs/examples/vcs/update-external-deployments.md +18 -0
- package/package.json +3 -2
- package/src/client.ts +2 -2
- package/src/index.ts +4 -0
- package/src/models.ts +863 -233
- package/src/query.ts +1 -1
- package/src/role.ts +72 -6
- package/src/services/account.ts +1052 -1055
- package/src/services/assistant.ts +38 -0
- package/src/services/avatars.ts +338 -337
- package/src/services/console.ts +16 -16
- package/src/services/databases.ts +2170 -2140
- package/src/services/functions.ts +804 -657
- package/src/services/graphql.ts +47 -47
- package/src/services/health.ts +373 -204
- package/src/services/locale.ts +156 -137
- package/src/services/migrations.ts +707 -0
- package/src/services/project.ts +178 -20
- package/src/services/projects.ts +1511 -1256
- package/src/services/proxy.ts +150 -0
- package/src/services/storage.ts +572 -577
- package/src/services/teams.ts +498 -501
- package/src/services/users.ts +1091 -1001
- package/src/services/vcs.ts +272 -0
- package/types/index.d.ts +4 -0
- package/types/models.d.ts +863 -233
- package/types/role.d.ts +62 -0
- package/types/services/account.d.ts +116 -104
- package/types/services/assistant.d.ts +14 -0
- package/types/services/avatars.d.ts +18 -17
- package/types/services/console.d.ts +2 -2
- package/types/services/databases.d.ts +111 -105
- package/types/services/functions.d.ts +95 -55
- package/types/services/graphql.d.ts +4 -4
- package/types/services/health.d.ts +97 -26
- package/types/services/locale.d.ts +24 -14
- package/types/services/migrations.d.ts +185 -0
- package/types/services/project.d.ts +60 -3
- package/types/services/projects.d.ts +174 -104
- package/types/services/proxy.d.ts +59 -0
- package/types/services/storage.d.ts +29 -28
- package/types/services/teams.d.ts +36 -35
- package/types/services/users.d.ts +105 -66
- package/types/services/vcs.d.ts +97 -0
- package/docs/examples/projects/update-domain-verification.md +0 -18
package/src/services/storage.ts
CHANGED
|
@@ -10,682 +10,677 @@ export class Storage extends Service {
|
|
|
10
10
|
super(client);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (typeof search !== 'undefined') {
|
|
33
|
-
payload['search'] = search;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const uri = new URL(this.client.config.endpoint + path);
|
|
37
|
-
return await this.client.call('get', uri, {
|
|
38
|
-
'content-type': 'application/json',
|
|
39
|
-
}, payload);
|
|
13
|
+
/**
|
|
14
|
+
* List buckets
|
|
15
|
+
*
|
|
16
|
+
* Get a list of all the storage buckets. You can use the query params to
|
|
17
|
+
* filter your results.
|
|
18
|
+
*
|
|
19
|
+
* @param {string[]} queries
|
|
20
|
+
* @param {string} search
|
|
21
|
+
* @throws {AppwriteException}
|
|
22
|
+
* @returns {Promise}
|
|
23
|
+
*/
|
|
24
|
+
async listBuckets(queries?: string[], search?: string): Promise<Models.BucketList> {
|
|
25
|
+
const apiPath = '/storage/buckets';
|
|
26
|
+
const payload: Payload = {};
|
|
27
|
+
|
|
28
|
+
if (typeof queries !== 'undefined') {
|
|
29
|
+
payload['queries'] = queries;
|
|
40
30
|
}
|
|
41
31
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* Create a new storage bucket.
|
|
46
|
-
*
|
|
47
|
-
* @param {string} bucketId
|
|
48
|
-
* @param {string} name
|
|
49
|
-
* @param {string[]} permissions
|
|
50
|
-
* @param {boolean} fileSecurity
|
|
51
|
-
* @param {boolean} enabled
|
|
52
|
-
* @param {number} maximumFileSize
|
|
53
|
-
* @param {string[]} allowedFileExtensions
|
|
54
|
-
* @param {string} compression
|
|
55
|
-
* @param {boolean} encryption
|
|
56
|
-
* @param {boolean} antivirus
|
|
57
|
-
* @throws {AppwriteException}
|
|
58
|
-
* @returns {Promise}
|
|
59
|
-
*/
|
|
60
|
-
async createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
|
|
61
|
-
if (typeof bucketId === 'undefined') {
|
|
62
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (typeof name === 'undefined') {
|
|
66
|
-
throw new AppwriteException('Missing required parameter: "name"');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let path = '/storage/buckets';
|
|
70
|
-
let payload: Payload = {};
|
|
71
|
-
|
|
72
|
-
if (typeof bucketId !== 'undefined') {
|
|
73
|
-
payload['bucketId'] = bucketId;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (typeof name !== 'undefined') {
|
|
77
|
-
payload['name'] = name;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (typeof permissions !== 'undefined') {
|
|
81
|
-
payload['permissions'] = permissions;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (typeof fileSecurity !== 'undefined') {
|
|
85
|
-
payload['fileSecurity'] = fileSecurity;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (typeof enabled !== 'undefined') {
|
|
89
|
-
payload['enabled'] = enabled;
|
|
90
|
-
}
|
|
32
|
+
if (typeof search !== 'undefined') {
|
|
33
|
+
payload['search'] = search;
|
|
34
|
+
}
|
|
91
35
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
36
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
37
|
+
return await this.client.call('get', uri, {
|
|
38
|
+
'content-type': 'application/json',
|
|
39
|
+
}, payload);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create bucket
|
|
44
|
+
*
|
|
45
|
+
* Create a new storage bucket.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} bucketId
|
|
48
|
+
* @param {string} name
|
|
49
|
+
* @param {string[]} permissions
|
|
50
|
+
* @param {boolean} fileSecurity
|
|
51
|
+
* @param {boolean} enabled
|
|
52
|
+
* @param {number} maximumFileSize
|
|
53
|
+
* @param {string[]} allowedFileExtensions
|
|
54
|
+
* @param {string} compression
|
|
55
|
+
* @param {boolean} encryption
|
|
56
|
+
* @param {boolean} antivirus
|
|
57
|
+
* @throws {AppwriteException}
|
|
58
|
+
* @returns {Promise}
|
|
59
|
+
*/
|
|
60
|
+
async createBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
|
|
61
|
+
if (typeof bucketId === 'undefined') {
|
|
62
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
63
|
+
}
|
|
95
64
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
65
|
+
if (typeof name === 'undefined') {
|
|
66
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
67
|
+
}
|
|
99
68
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
69
|
+
const apiPath = '/storage/buckets';
|
|
70
|
+
const payload: Payload = {};
|
|
103
71
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
72
|
+
if (typeof bucketId !== 'undefined') {
|
|
73
|
+
payload['bucketId'] = bucketId;
|
|
74
|
+
}
|
|
107
75
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
76
|
+
if (typeof name !== 'undefined') {
|
|
77
|
+
payload['name'] = name;
|
|
78
|
+
}
|
|
111
79
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
'content-type': 'application/json',
|
|
115
|
-
}, payload);
|
|
80
|
+
if (typeof permissions !== 'undefined') {
|
|
81
|
+
payload['permissions'] = permissions;
|
|
116
82
|
}
|
|
117
83
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* Get a storage bucket by its unique ID. This endpoint response returns a
|
|
122
|
-
* JSON object with the storage bucket metadata.
|
|
123
|
-
*
|
|
124
|
-
* @param {string} bucketId
|
|
125
|
-
* @throws {AppwriteException}
|
|
126
|
-
* @returns {Promise}
|
|
127
|
-
*/
|
|
128
|
-
async getBucket(bucketId: string): Promise<Models.Bucket> {
|
|
129
|
-
if (typeof bucketId === 'undefined') {
|
|
130
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
131
|
-
}
|
|
84
|
+
if (typeof fileSecurity !== 'undefined') {
|
|
85
|
+
payload['fileSecurity'] = fileSecurity;
|
|
86
|
+
}
|
|
132
87
|
|
|
133
|
-
|
|
134
|
-
|
|
88
|
+
if (typeof enabled !== 'undefined') {
|
|
89
|
+
payload['enabled'] = enabled;
|
|
90
|
+
}
|
|
135
91
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
'content-type': 'application/json',
|
|
139
|
-
}, payload);
|
|
92
|
+
if (typeof maximumFileSize !== 'undefined') {
|
|
93
|
+
payload['maximumFileSize'] = maximumFileSize;
|
|
140
94
|
}
|
|
141
95
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* Update a storage bucket by its unique ID.
|
|
146
|
-
*
|
|
147
|
-
* @param {string} bucketId
|
|
148
|
-
* @param {string} name
|
|
149
|
-
* @param {string[]} permissions
|
|
150
|
-
* @param {boolean} fileSecurity
|
|
151
|
-
* @param {boolean} enabled
|
|
152
|
-
* @param {number} maximumFileSize
|
|
153
|
-
* @param {string[]} allowedFileExtensions
|
|
154
|
-
* @param {string} compression
|
|
155
|
-
* @param {boolean} encryption
|
|
156
|
-
* @param {boolean} antivirus
|
|
157
|
-
* @throws {AppwriteException}
|
|
158
|
-
* @returns {Promise}
|
|
159
|
-
*/
|
|
160
|
-
async updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
|
|
161
|
-
if (typeof bucketId === 'undefined') {
|
|
162
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
163
|
-
}
|
|
96
|
+
if (typeof allowedFileExtensions !== 'undefined') {
|
|
97
|
+
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
98
|
+
}
|
|
164
99
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
100
|
+
if (typeof compression !== 'undefined') {
|
|
101
|
+
payload['compression'] = compression;
|
|
102
|
+
}
|
|
168
103
|
|
|
169
|
-
|
|
170
|
-
|
|
104
|
+
if (typeof encryption !== 'undefined') {
|
|
105
|
+
payload['encryption'] = encryption;
|
|
106
|
+
}
|
|
171
107
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
108
|
+
if (typeof antivirus !== 'undefined') {
|
|
109
|
+
payload['antivirus'] = antivirus;
|
|
110
|
+
}
|
|
175
111
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
112
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
113
|
+
return await this.client.call('post', uri, {
|
|
114
|
+
'content-type': 'application/json',
|
|
115
|
+
}, payload);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get bucket
|
|
120
|
+
*
|
|
121
|
+
* Get a storage bucket by its unique ID. This endpoint response returns a
|
|
122
|
+
* JSON object with the storage bucket metadata.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} bucketId
|
|
125
|
+
* @throws {AppwriteException}
|
|
126
|
+
* @returns {Promise}
|
|
127
|
+
*/
|
|
128
|
+
async getBucket(bucketId: string): Promise<Models.Bucket> {
|
|
129
|
+
if (typeof bucketId === 'undefined') {
|
|
130
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
131
|
+
}
|
|
179
132
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
133
|
+
const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
134
|
+
const payload: Payload = {};
|
|
135
|
+
|
|
136
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
137
|
+
return await this.client.call('get', uri, {
|
|
138
|
+
'content-type': 'application/json',
|
|
139
|
+
}, payload);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Update bucket
|
|
144
|
+
*
|
|
145
|
+
* Update a storage bucket by its unique ID.
|
|
146
|
+
*
|
|
147
|
+
* @param {string} bucketId
|
|
148
|
+
* @param {string} name
|
|
149
|
+
* @param {string[]} permissions
|
|
150
|
+
* @param {boolean} fileSecurity
|
|
151
|
+
* @param {boolean} enabled
|
|
152
|
+
* @param {number} maximumFileSize
|
|
153
|
+
* @param {string[]} allowedFileExtensions
|
|
154
|
+
* @param {string} compression
|
|
155
|
+
* @param {boolean} encryption
|
|
156
|
+
* @param {boolean} antivirus
|
|
157
|
+
* @throws {AppwriteException}
|
|
158
|
+
* @returns {Promise}
|
|
159
|
+
*/
|
|
160
|
+
async updateBucket(bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: string, encryption?: boolean, antivirus?: boolean): Promise<Models.Bucket> {
|
|
161
|
+
if (typeof bucketId === 'undefined') {
|
|
162
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
163
|
+
}
|
|
183
164
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
165
|
+
if (typeof name === 'undefined') {
|
|
166
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
167
|
+
}
|
|
187
168
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
169
|
+
const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
170
|
+
const payload: Payload = {};
|
|
191
171
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
172
|
+
if (typeof name !== 'undefined') {
|
|
173
|
+
payload['name'] = name;
|
|
174
|
+
}
|
|
195
175
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
176
|
+
if (typeof permissions !== 'undefined') {
|
|
177
|
+
payload['permissions'] = permissions;
|
|
178
|
+
}
|
|
199
179
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
180
|
+
if (typeof fileSecurity !== 'undefined') {
|
|
181
|
+
payload['fileSecurity'] = fileSecurity;
|
|
182
|
+
}
|
|
203
183
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
184
|
+
if (typeof enabled !== 'undefined') {
|
|
185
|
+
payload['enabled'] = enabled;
|
|
186
|
+
}
|
|
207
187
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
'content-type': 'application/json',
|
|
211
|
-
}, payload);
|
|
188
|
+
if (typeof maximumFileSize !== 'undefined') {
|
|
189
|
+
payload['maximumFileSize'] = maximumFileSize;
|
|
212
190
|
}
|
|
213
191
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
* Delete a storage bucket by its unique ID.
|
|
218
|
-
*
|
|
219
|
-
* @param {string} bucketId
|
|
220
|
-
* @throws {AppwriteException}
|
|
221
|
-
* @returns {Promise}
|
|
222
|
-
*/
|
|
223
|
-
async deleteBucket(bucketId: string): Promise<{}> {
|
|
224
|
-
if (typeof bucketId === 'undefined') {
|
|
225
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
226
|
-
}
|
|
192
|
+
if (typeof allowedFileExtensions !== 'undefined') {
|
|
193
|
+
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
194
|
+
}
|
|
227
195
|
|
|
228
|
-
|
|
229
|
-
|
|
196
|
+
if (typeof compression !== 'undefined') {
|
|
197
|
+
payload['compression'] = compression;
|
|
198
|
+
}
|
|
230
199
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
'content-type': 'application/json',
|
|
234
|
-
}, payload);
|
|
200
|
+
if (typeof encryption !== 'undefined') {
|
|
201
|
+
payload['encryption'] = encryption;
|
|
235
202
|
}
|
|
236
203
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
* Get a list of all the user files. You can use the query params to filter
|
|
241
|
-
* your results.
|
|
242
|
-
*
|
|
243
|
-
* @param {string} bucketId
|
|
244
|
-
* @param {string[]} queries
|
|
245
|
-
* @param {string} search
|
|
246
|
-
* @throws {AppwriteException}
|
|
247
|
-
* @returns {Promise}
|
|
248
|
-
*/
|
|
249
|
-
async listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList> {
|
|
250
|
-
if (typeof bucketId === 'undefined') {
|
|
251
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
252
|
-
}
|
|
204
|
+
if (typeof antivirus !== 'undefined') {
|
|
205
|
+
payload['antivirus'] = antivirus;
|
|
206
|
+
}
|
|
253
207
|
|
|
254
|
-
|
|
255
|
-
|
|
208
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
209
|
+
return await this.client.call('put', uri, {
|
|
210
|
+
'content-type': 'application/json',
|
|
211
|
+
}, payload);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Delete bucket
|
|
216
|
+
*
|
|
217
|
+
* Delete a storage bucket by its unique ID.
|
|
218
|
+
*
|
|
219
|
+
* @param {string} bucketId
|
|
220
|
+
* @throws {AppwriteException}
|
|
221
|
+
* @returns {Promise}
|
|
222
|
+
*/
|
|
223
|
+
async deleteBucket(bucketId: string): Promise<{}> {
|
|
224
|
+
if (typeof bucketId === 'undefined') {
|
|
225
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
226
|
+
}
|
|
256
227
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
228
|
+
const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
229
|
+
const payload: Payload = {};
|
|
230
|
+
|
|
231
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
232
|
+
return await this.client.call('delete', uri, {
|
|
233
|
+
'content-type': 'application/json',
|
|
234
|
+
}, payload);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* List files
|
|
239
|
+
*
|
|
240
|
+
* Get a list of all the user files. You can use the query params to filter
|
|
241
|
+
* your results.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} bucketId
|
|
244
|
+
* @param {string[]} queries
|
|
245
|
+
* @param {string} search
|
|
246
|
+
* @throws {AppwriteException}
|
|
247
|
+
* @returns {Promise}
|
|
248
|
+
*/
|
|
249
|
+
async listFiles(bucketId: string, queries?: string[], search?: string): Promise<Models.FileList> {
|
|
250
|
+
if (typeof bucketId === 'undefined') {
|
|
251
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
252
|
+
}
|
|
260
253
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
254
|
+
const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
255
|
+
const payload: Payload = {};
|
|
264
256
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
'content-type': 'application/json',
|
|
268
|
-
}, payload);
|
|
257
|
+
if (typeof queries !== 'undefined') {
|
|
258
|
+
payload['queries'] = queries;
|
|
269
259
|
}
|
|
270
260
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
* Create a new file. Before using this route, you should create a new bucket
|
|
275
|
-
* resource using either a [server
|
|
276
|
-
* integration](/docs/server/storage#storageCreateBucket) API or directly from
|
|
277
|
-
* your Appwrite console.
|
|
278
|
-
*
|
|
279
|
-
* Larger files should be uploaded using multiple requests with the
|
|
280
|
-
* [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
|
|
281
|
-
* header to send a partial request with a maximum supported chunk of `5MB`.
|
|
282
|
-
* The `content-range` header values should always be in bytes.
|
|
283
|
-
*
|
|
284
|
-
* When the first request is sent, the server will return the **File** object,
|
|
285
|
-
* and the subsequent part request must include the file's **id** in
|
|
286
|
-
* `x-appwrite-id` header to allow the server to know that the partial upload
|
|
287
|
-
* is for the existing file and not for a new one.
|
|
288
|
-
*
|
|
289
|
-
* If you're creating a new file using one of the Appwrite SDKs, all the
|
|
290
|
-
* chunking logic will be managed by the SDK internally.
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* @param {string} bucketId
|
|
294
|
-
* @param {string} fileId
|
|
295
|
-
* @param {File} file
|
|
296
|
-
* @param {string[]} permissions
|
|
297
|
-
* @throws {AppwriteException}
|
|
298
|
-
* @returns {Promise}
|
|
299
|
-
*/
|
|
300
|
-
async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> {
|
|
301
|
-
if (typeof bucketId === 'undefined') {
|
|
302
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (typeof fileId === 'undefined') {
|
|
306
|
-
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
307
|
-
}
|
|
261
|
+
if (typeof search !== 'undefined') {
|
|
262
|
+
payload['search'] = search;
|
|
263
|
+
}
|
|
308
264
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
265
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
266
|
+
return await this.client.call('get', uri, {
|
|
267
|
+
'content-type': 'application/json',
|
|
268
|
+
}, payload);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Create file
|
|
273
|
+
*
|
|
274
|
+
* Create a new file. Before using this route, you should create a new bucket
|
|
275
|
+
* resource using either a [server
|
|
276
|
+
* integration](https://appwrite.io/docs/server/storage#storageCreateBucket)
|
|
277
|
+
* API or directly from your Appwrite console.
|
|
278
|
+
*
|
|
279
|
+
* Larger files should be uploaded using multiple requests with the
|
|
280
|
+
* [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
|
|
281
|
+
* header to send a partial request with a maximum supported chunk of `5MB`.
|
|
282
|
+
* The `content-range` header values should always be in bytes.
|
|
283
|
+
*
|
|
284
|
+
* When the first request is sent, the server will return the **File** object,
|
|
285
|
+
* and the subsequent part request must include the file's **id** in
|
|
286
|
+
* `x-appwrite-id` header to allow the server to know that the partial upload
|
|
287
|
+
* is for the existing file and not for a new one.
|
|
288
|
+
*
|
|
289
|
+
* If you're creating a new file using one of the Appwrite SDKs, all the
|
|
290
|
+
* chunking logic will be managed by the SDK internally.
|
|
291
|
+
*
|
|
292
|
+
*
|
|
293
|
+
* @param {string} bucketId
|
|
294
|
+
* @param {string} fileId
|
|
295
|
+
* @param {File} file
|
|
296
|
+
* @param {string[]} permissions
|
|
297
|
+
* @throws {AppwriteException}
|
|
298
|
+
* @returns {Promise}
|
|
299
|
+
*/
|
|
300
|
+
async createFile(bucketId: string, fileId: string, file: File, permissions?: string[], onProgress = (progress: UploadProgress) => {}): Promise<Models.File> {
|
|
301
|
+
if (typeof bucketId === 'undefined') {
|
|
302
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
303
|
+
}
|
|
312
304
|
|
|
313
|
-
|
|
314
|
-
|
|
305
|
+
if (typeof fileId === 'undefined') {
|
|
306
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
307
|
+
}
|
|
315
308
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
309
|
+
if (typeof file === 'undefined') {
|
|
310
|
+
throw new AppwriteException('Missing required parameter: "file"');
|
|
311
|
+
}
|
|
319
312
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
313
|
+
const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
314
|
+
const payload: Payload = {};
|
|
323
315
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
316
|
+
if (typeof fileId !== 'undefined') {
|
|
317
|
+
payload['fileId'] = fileId;
|
|
318
|
+
}
|
|
327
319
|
|
|
328
|
-
|
|
320
|
+
if (typeof file !== 'undefined') {
|
|
321
|
+
payload['file'] = file;
|
|
322
|
+
}
|
|
329
323
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
324
|
+
if (typeof permissions !== 'undefined') {
|
|
325
|
+
payload['permissions'] = permissions;
|
|
326
|
+
}
|
|
333
327
|
|
|
334
|
-
|
|
328
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
335
329
|
|
|
336
|
-
|
|
337
|
-
|
|
330
|
+
if(!(file instanceof File)) {
|
|
331
|
+
throw new AppwriteException('Parameter "file" has to be a File.');
|
|
332
|
+
}
|
|
338
333
|
|
|
339
|
-
|
|
340
|
-
}, payload);
|
|
341
|
-
}
|
|
342
|
-
let id = undefined;
|
|
343
|
-
let response = undefined;
|
|
334
|
+
const size = file.size;
|
|
344
335
|
|
|
345
|
-
|
|
336
|
+
if (size <= Service.CHUNK_SIZE) {
|
|
337
|
+
return await this.client.call('post', uri, {
|
|
346
338
|
'content-type': 'multipart/form-data',
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
let counter = 0;
|
|
350
|
-
const totalCounters = Math.ceil(size / Service.CHUNK_SIZE);
|
|
351
|
-
if(fileId != 'unique()') {
|
|
352
|
-
try {
|
|
353
|
-
response = await this.client.call('GET', new URL(this.client.config.endpoint + path + '/' + fileId), headers);
|
|
354
|
-
counter = response.chunksUploaded;
|
|
355
|
-
} catch(e) {
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
for (counter; counter < totalCounters; counter++) {
|
|
360
|
-
const start = (counter * Service.CHUNK_SIZE);
|
|
361
|
-
const end = Math.min((((counter * Service.CHUNK_SIZE) + Service.CHUNK_SIZE) - 1), size);
|
|
362
|
-
|
|
363
|
-
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
|
|
364
|
-
|
|
365
|
-
if (id) {
|
|
366
|
-
headers['x-appwrite-id'] = id;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const stream = file.slice(start, end + 1);
|
|
370
|
-
payload['file'] = new File([stream], file.name);
|
|
371
|
-
|
|
372
|
-
response = await this.client.call('post', uri, headers, payload);
|
|
339
|
+
}, payload);
|
|
340
|
+
}
|
|
373
341
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
342
|
+
const apiHeaders: { [header: string]: string } = {
|
|
343
|
+
'content-type': 'multipart/form-data',
|
|
344
|
+
}
|
|
377
345
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
});
|
|
386
|
-
}
|
|
346
|
+
let offset = 0;
|
|
347
|
+
let response = undefined;
|
|
348
|
+
if(fileId != 'unique()') {
|
|
349
|
+
try {
|
|
350
|
+
response = await this.client.call('GET', new URL(this.client.config.endpoint + apiPath + '/' + fileId), apiHeaders);
|
|
351
|
+
offset = response.chunksUploaded * Service.CHUNK_SIZE;
|
|
352
|
+
} catch(e) {
|
|
387
353
|
}
|
|
354
|
+
}
|
|
388
355
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Get File
|
|
394
|
-
*
|
|
395
|
-
* Get a file by its unique ID. This endpoint response returns a JSON object
|
|
396
|
-
* with the file metadata.
|
|
397
|
-
*
|
|
398
|
-
* @param {string} bucketId
|
|
399
|
-
* @param {string} fileId
|
|
400
|
-
* @throws {AppwriteException}
|
|
401
|
-
* @returns {Promise}
|
|
402
|
-
*/
|
|
403
|
-
async getFile(bucketId: string, fileId: string): Promise<Models.File> {
|
|
404
|
-
if (typeof bucketId === 'undefined') {
|
|
405
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
406
|
-
}
|
|
356
|
+
while (offset < size) {
|
|
357
|
+
let end = Math.min(offset + Service.CHUNK_SIZE - 1, size - 1);
|
|
407
358
|
|
|
408
|
-
|
|
409
|
-
|
|
359
|
+
apiHeaders['content-range'] = 'bytes ' + offset + '-' + end + '/' + size;
|
|
360
|
+
if (response && response.$id) {
|
|
361
|
+
apiHeaders['x-appwrite-id'] = response.$id;
|
|
410
362
|
}
|
|
411
363
|
|
|
412
|
-
|
|
413
|
-
|
|
364
|
+
const chunk = file.slice(offset, end + 1);
|
|
365
|
+
payload['file'] = new File([chunk], file.name);
|
|
366
|
+
response = await this.client.call('post', uri, apiHeaders, payload);
|
|
414
367
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
*
|
|
424
|
-
* Update a file by its unique ID. Only users with write permissions have
|
|
425
|
-
* access to update this resource.
|
|
426
|
-
*
|
|
427
|
-
* @param {string} bucketId
|
|
428
|
-
* @param {string} fileId
|
|
429
|
-
* @param {string[]} permissions
|
|
430
|
-
* @throws {AppwriteException}
|
|
431
|
-
* @returns {Promise}
|
|
432
|
-
*/
|
|
433
|
-
async updateFile(bucketId: string, fileId: string, permissions?: string[]): Promise<Models.File> {
|
|
434
|
-
if (typeof bucketId === 'undefined') {
|
|
435
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
if (typeof fileId === 'undefined') {
|
|
439
|
-
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
368
|
+
if (onProgress) {
|
|
369
|
+
onProgress({
|
|
370
|
+
$id: response.$id,
|
|
371
|
+
progress: (offset / size) * 100,
|
|
372
|
+
sizeUploaded: offset,
|
|
373
|
+
chunksTotal: response.chunksTotal,
|
|
374
|
+
chunksUploaded: response.chunksUploaded
|
|
375
|
+
});
|
|
440
376
|
}
|
|
377
|
+
offset += Service.CHUNK_SIZE;
|
|
378
|
+
}
|
|
379
|
+
return response;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Get file
|
|
384
|
+
*
|
|
385
|
+
* Get a file by its unique ID. This endpoint response returns a JSON object
|
|
386
|
+
* with the file metadata.
|
|
387
|
+
*
|
|
388
|
+
* @param {string} bucketId
|
|
389
|
+
* @param {string} fileId
|
|
390
|
+
* @throws {AppwriteException}
|
|
391
|
+
* @returns {Promise}
|
|
392
|
+
*/
|
|
393
|
+
async getFile(bucketId: string, fileId: string): Promise<Models.File> {
|
|
394
|
+
if (typeof bucketId === 'undefined') {
|
|
395
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
396
|
+
}
|
|
441
397
|
|
|
442
|
-
|
|
443
|
-
|
|
398
|
+
if (typeof fileId === 'undefined') {
|
|
399
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
400
|
+
}
|
|
444
401
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
402
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
403
|
+
const payload: Payload = {};
|
|
404
|
+
|
|
405
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
406
|
+
return await this.client.call('get', uri, {
|
|
407
|
+
'content-type': 'application/json',
|
|
408
|
+
}, payload);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Update file
|
|
413
|
+
*
|
|
414
|
+
* Update a file by its unique ID. Only users with write permissions have
|
|
415
|
+
* access to update this resource.
|
|
416
|
+
*
|
|
417
|
+
* @param {string} bucketId
|
|
418
|
+
* @param {string} fileId
|
|
419
|
+
* @param {string} name
|
|
420
|
+
* @param {string[]} permissions
|
|
421
|
+
* @throws {AppwriteException}
|
|
422
|
+
* @returns {Promise}
|
|
423
|
+
*/
|
|
424
|
+
async updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File> {
|
|
425
|
+
if (typeof bucketId === 'undefined') {
|
|
426
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
427
|
+
}
|
|
448
428
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
'content-type': 'application/json',
|
|
452
|
-
}, payload);
|
|
429
|
+
if (typeof fileId === 'undefined') {
|
|
430
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
453
431
|
}
|
|
454
432
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
*
|
|
458
|
-
* Delete a file by its unique ID. Only users with write permissions have
|
|
459
|
-
* access to delete this resource.
|
|
460
|
-
*
|
|
461
|
-
* @param {string} bucketId
|
|
462
|
-
* @param {string} fileId
|
|
463
|
-
* @throws {AppwriteException}
|
|
464
|
-
* @returns {Promise}
|
|
465
|
-
*/
|
|
466
|
-
async deleteFile(bucketId: string, fileId: string): Promise<{}> {
|
|
467
|
-
if (typeof bucketId === 'undefined') {
|
|
468
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
469
|
-
}
|
|
433
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
434
|
+
const payload: Payload = {};
|
|
470
435
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
436
|
+
if (typeof name !== 'undefined') {
|
|
437
|
+
payload['name'] = name;
|
|
438
|
+
}
|
|
474
439
|
|
|
475
|
-
|
|
476
|
-
|
|
440
|
+
if (typeof permissions !== 'undefined') {
|
|
441
|
+
payload['permissions'] = permissions;
|
|
442
|
+
}
|
|
477
443
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
444
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
445
|
+
return await this.client.call('put', uri, {
|
|
446
|
+
'content-type': 'application/json',
|
|
447
|
+
}, payload);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Delete File
|
|
452
|
+
*
|
|
453
|
+
* Delete a file by its unique ID. Only users with write permissions have
|
|
454
|
+
* access to delete this resource.
|
|
455
|
+
*
|
|
456
|
+
* @param {string} bucketId
|
|
457
|
+
* @param {string} fileId
|
|
458
|
+
* @throws {AppwriteException}
|
|
459
|
+
* @returns {Promise}
|
|
460
|
+
*/
|
|
461
|
+
async deleteFile(bucketId: string, fileId: string): Promise<{}> {
|
|
462
|
+
if (typeof bucketId === 'undefined') {
|
|
463
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
482
464
|
}
|
|
483
465
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
* Get a file content by its unique ID. The endpoint response return with a
|
|
488
|
-
* 'Content-Disposition: attachment' header that tells the browser to start
|
|
489
|
-
* downloading the file to user downloads directory.
|
|
490
|
-
*
|
|
491
|
-
* @param {string} bucketId
|
|
492
|
-
* @param {string} fileId
|
|
493
|
-
* @throws {AppwriteException}
|
|
494
|
-
* @returns {URL}
|
|
495
|
-
*/
|
|
496
|
-
getFileDownload(bucketId: string, fileId: string): URL {
|
|
497
|
-
if (typeof bucketId === 'undefined') {
|
|
498
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
499
|
-
}
|
|
466
|
+
if (typeof fileId === 'undefined') {
|
|
467
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
468
|
+
}
|
|
500
469
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
470
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
471
|
+
const payload: Payload = {};
|
|
472
|
+
|
|
473
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
474
|
+
return await this.client.call('delete', uri, {
|
|
475
|
+
'content-type': 'application/json',
|
|
476
|
+
}, payload);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Get file for download
|
|
481
|
+
*
|
|
482
|
+
* Get a file content by its unique ID. The endpoint response return with a
|
|
483
|
+
* 'Content-Disposition: attachment' header that tells the browser to start
|
|
484
|
+
* downloading the file to user downloads directory.
|
|
485
|
+
*
|
|
486
|
+
* @param {string} bucketId
|
|
487
|
+
* @param {string} fileId
|
|
488
|
+
* @throws {AppwriteException}
|
|
489
|
+
* @returns {URL}
|
|
490
|
+
*/
|
|
491
|
+
getFileDownload(bucketId: string, fileId: string): URL {
|
|
492
|
+
if (typeof bucketId === 'undefined') {
|
|
493
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
494
|
+
}
|
|
504
495
|
|
|
505
|
-
|
|
506
|
-
|
|
496
|
+
if (typeof fileId === 'undefined') {
|
|
497
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
498
|
+
}
|
|
507
499
|
|
|
508
|
-
|
|
509
|
-
|
|
500
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
501
|
+
const payload: Payload = {};
|
|
510
502
|
|
|
503
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
504
|
+
payload['project'] = this.client.config.project;
|
|
511
505
|
|
|
512
|
-
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
513
|
-
uri.searchParams.append(key, value);
|
|
514
|
-
}
|
|
515
|
-
return uri;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Get File Preview
|
|
520
|
-
*
|
|
521
|
-
* Get a file preview image. Currently, this method supports preview for image
|
|
522
|
-
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
523
|
-
* and spreadsheets, will return the file icon image. You can also pass query
|
|
524
|
-
* string arguments for cutting and resizing your preview image. Preview is
|
|
525
|
-
* supported only for image files smaller than 10MB.
|
|
526
|
-
*
|
|
527
|
-
* @param {string} bucketId
|
|
528
|
-
* @param {string} fileId
|
|
529
|
-
* @param {number} width
|
|
530
|
-
* @param {number} height
|
|
531
|
-
* @param {string} gravity
|
|
532
|
-
* @param {number} quality
|
|
533
|
-
* @param {number} borderWidth
|
|
534
|
-
* @param {string} borderColor
|
|
535
|
-
* @param {number} borderRadius
|
|
536
|
-
* @param {number} opacity
|
|
537
|
-
* @param {number} rotation
|
|
538
|
-
* @param {string} background
|
|
539
|
-
* @param {string} output
|
|
540
|
-
* @throws {AppwriteException}
|
|
541
|
-
* @returns {URL}
|
|
542
|
-
*/
|
|
543
|
-
getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL {
|
|
544
|
-
if (typeof bucketId === 'undefined') {
|
|
545
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
546
|
-
}
|
|
547
506
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
507
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
508
|
+
uri.searchParams.append(key, value);
|
|
509
|
+
}
|
|
510
|
+
return uri;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Get file preview
|
|
515
|
+
*
|
|
516
|
+
* Get a file preview image. Currently, this method supports preview for image
|
|
517
|
+
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
518
|
+
* and spreadsheets, will return the file icon image. You can also pass query
|
|
519
|
+
* string arguments for cutting and resizing your preview image. Preview is
|
|
520
|
+
* supported only for image files smaller than 10MB.
|
|
521
|
+
*
|
|
522
|
+
* @param {string} bucketId
|
|
523
|
+
* @param {string} fileId
|
|
524
|
+
* @param {number} width
|
|
525
|
+
* @param {number} height
|
|
526
|
+
* @param {string} gravity
|
|
527
|
+
* @param {number} quality
|
|
528
|
+
* @param {number} borderWidth
|
|
529
|
+
* @param {string} borderColor
|
|
530
|
+
* @param {number} borderRadius
|
|
531
|
+
* @param {number} opacity
|
|
532
|
+
* @param {number} rotation
|
|
533
|
+
* @param {string} background
|
|
534
|
+
* @param {string} output
|
|
535
|
+
* @throws {AppwriteException}
|
|
536
|
+
* @returns {URL}
|
|
537
|
+
*/
|
|
538
|
+
getFilePreview(bucketId: string, fileId: string, width?: number, height?: number, gravity?: string, quality?: number, borderWidth?: number, borderColor?: string, borderRadius?: number, opacity?: number, rotation?: number, background?: string, output?: string): URL {
|
|
539
|
+
if (typeof bucketId === 'undefined') {
|
|
540
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
541
|
+
}
|
|
551
542
|
|
|
552
|
-
|
|
553
|
-
|
|
543
|
+
if (typeof fileId === 'undefined') {
|
|
544
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
545
|
+
}
|
|
554
546
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
547
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
548
|
+
const payload: Payload = {};
|
|
558
549
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
550
|
+
if (typeof width !== 'undefined') {
|
|
551
|
+
payload['width'] = width;
|
|
552
|
+
}
|
|
562
553
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
554
|
+
if (typeof height !== 'undefined') {
|
|
555
|
+
payload['height'] = height;
|
|
556
|
+
}
|
|
566
557
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
558
|
+
if (typeof gravity !== 'undefined') {
|
|
559
|
+
payload['gravity'] = gravity;
|
|
560
|
+
}
|
|
570
561
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
562
|
+
if (typeof quality !== 'undefined') {
|
|
563
|
+
payload['quality'] = quality;
|
|
564
|
+
}
|
|
574
565
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
566
|
+
if (typeof borderWidth !== 'undefined') {
|
|
567
|
+
payload['borderWidth'] = borderWidth;
|
|
568
|
+
}
|
|
578
569
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
570
|
+
if (typeof borderColor !== 'undefined') {
|
|
571
|
+
payload['borderColor'] = borderColor;
|
|
572
|
+
}
|
|
582
573
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
574
|
+
if (typeof borderRadius !== 'undefined') {
|
|
575
|
+
payload['borderRadius'] = borderRadius;
|
|
576
|
+
}
|
|
586
577
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
578
|
+
if (typeof opacity !== 'undefined') {
|
|
579
|
+
payload['opacity'] = opacity;
|
|
580
|
+
}
|
|
590
581
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
582
|
+
if (typeof rotation !== 'undefined') {
|
|
583
|
+
payload['rotation'] = rotation;
|
|
584
|
+
}
|
|
594
585
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
586
|
+
if (typeof background !== 'undefined') {
|
|
587
|
+
payload['background'] = background;
|
|
588
|
+
}
|
|
598
589
|
|
|
599
|
-
|
|
600
|
-
payload['
|
|
590
|
+
if (typeof output !== 'undefined') {
|
|
591
|
+
payload['output'] = output;
|
|
592
|
+
}
|
|
601
593
|
|
|
594
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
595
|
+
payload['project'] = this.client.config.project;
|
|
602
596
|
|
|
603
|
-
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
604
|
-
uri.searchParams.append(key, value);
|
|
605
|
-
}
|
|
606
|
-
return uri;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Get File for View
|
|
611
|
-
*
|
|
612
|
-
* Get a file content by its unique ID. This endpoint is similar to the
|
|
613
|
-
* download method but returns with no 'Content-Disposition: attachment'
|
|
614
|
-
* header.
|
|
615
|
-
*
|
|
616
|
-
* @param {string} bucketId
|
|
617
|
-
* @param {string} fileId
|
|
618
|
-
* @throws {AppwriteException}
|
|
619
|
-
* @returns {URL}
|
|
620
|
-
*/
|
|
621
|
-
getFileView(bucketId: string, fileId: string): URL {
|
|
622
|
-
if (typeof bucketId === 'undefined') {
|
|
623
|
-
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
624
|
-
}
|
|
625
597
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
598
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
599
|
+
uri.searchParams.append(key, value);
|
|
600
|
+
}
|
|
601
|
+
return uri;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Get file for view
|
|
606
|
+
*
|
|
607
|
+
* Get a file content by its unique ID. This endpoint is similar to the
|
|
608
|
+
* download method but returns with no 'Content-Disposition: attachment'
|
|
609
|
+
* header.
|
|
610
|
+
*
|
|
611
|
+
* @param {string} bucketId
|
|
612
|
+
* @param {string} fileId
|
|
613
|
+
* @throws {AppwriteException}
|
|
614
|
+
* @returns {URL}
|
|
615
|
+
*/
|
|
616
|
+
getFileView(bucketId: string, fileId: string): URL {
|
|
617
|
+
if (typeof bucketId === 'undefined') {
|
|
618
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
619
|
+
}
|
|
629
620
|
|
|
630
|
-
|
|
631
|
-
|
|
621
|
+
if (typeof fileId === 'undefined') {
|
|
622
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
623
|
+
}
|
|
632
624
|
|
|
633
|
-
|
|
634
|
-
|
|
625
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
626
|
+
const payload: Payload = {};
|
|
635
627
|
|
|
628
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
629
|
+
payload['project'] = this.client.config.project;
|
|
636
630
|
|
|
637
|
-
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
638
|
-
uri.searchParams.append(key, value);
|
|
639
|
-
}
|
|
640
|
-
return uri;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Get usage stats for storage
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
* @param {string} range
|
|
648
|
-
* @throws {AppwriteException}
|
|
649
|
-
* @returns {Promise}
|
|
650
|
-
*/
|
|
651
|
-
async getUsage(range?: string): Promise<Models.UsageStorage> {
|
|
652
|
-
let path = '/storage/usage';
|
|
653
|
-
let payload: Payload = {};
|
|
654
|
-
|
|
655
|
-
if (typeof range !== 'undefined') {
|
|
656
|
-
payload['range'] = range;
|
|
657
|
-
}
|
|
658
631
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
632
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
633
|
+
uri.searchParams.append(key, value);
|
|
634
|
+
}
|
|
635
|
+
return uri;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Get usage stats for storage
|
|
640
|
+
*
|
|
641
|
+
*
|
|
642
|
+
* @param {string} range
|
|
643
|
+
* @throws {AppwriteException}
|
|
644
|
+
* @returns {Promise}
|
|
645
|
+
*/
|
|
646
|
+
async getUsage(range?: string): Promise<Models.UsageStorage> {
|
|
647
|
+
const apiPath = '/storage/usage';
|
|
648
|
+
const payload: Payload = {};
|
|
649
|
+
|
|
650
|
+
if (typeof range !== 'undefined') {
|
|
651
|
+
payload['range'] = range;
|
|
663
652
|
}
|
|
664
653
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
654
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
655
|
+
return await this.client.call('get', uri, {
|
|
656
|
+
'content-type': 'application/json',
|
|
657
|
+
}, payload);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Get usage stats for storage bucket
|
|
662
|
+
*
|
|
663
|
+
*
|
|
664
|
+
* @param {string} bucketId
|
|
665
|
+
* @param {string} range
|
|
666
|
+
* @throws {AppwriteException}
|
|
667
|
+
* @returns {Promise}
|
|
668
|
+
*/
|
|
669
|
+
async getBucketUsage(bucketId: string, range?: string): Promise<Models.UsageBuckets> {
|
|
670
|
+
if (typeof bucketId === 'undefined') {
|
|
671
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
672
|
+
}
|
|
681
673
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
674
|
+
const apiPath = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
|
|
675
|
+
const payload: Payload = {};
|
|
685
676
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
'content-type': 'application/json',
|
|
689
|
-
}, payload);
|
|
677
|
+
if (typeof range !== 'undefined') {
|
|
678
|
+
payload['range'] = range;
|
|
690
679
|
}
|
|
680
|
+
|
|
681
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
682
|
+
return await this.client.call('get', uri, {
|
|
683
|
+
'content-type': 'application/json',
|
|
684
|
+
}, payload);
|
|
685
|
+
}
|
|
691
686
|
};
|