@appwrite.io/console 0.2.0 → 0.3.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/dist/cjs/sdk.js +2332 -633
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +2329 -634
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +2332 -633
- 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-with-invite-code.md +1 -1
- package/docs/examples/account/create.md +1 -1
- package/docs/examples/account/delete-identity.md +18 -0
- 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 +1 -1
- 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 +2 -2
- 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-certificates.md +1 -1
- 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-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 +1 -1
- 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/{list-domains.md → get-usage.md} +2 -2
- 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/{get-domain.md → update-personal-data-check.md} +2 -2
- package/docs/examples/projects/update-platform.md +1 -1
- package/docs/examples/projects/{delete-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/update-smtp-configuration.md +18 -0
- package/docs/examples/projects/{create-domain.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 +1 -1
- 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 +1 -1
- package/src/client.ts +2 -2
- package/src/index.ts +4 -0
- package/src/models.ts +905 -114
- package/src/services/account.ts +1102 -1055
- package/src/services/assistant.ts +38 -0
- package/src/services/avatars.ts +337 -337
- package/src/services/console.ts +16 -16
- package/src/services/databases.ts +2170 -2140
- package/src/services/functions.ts +808 -652
- package/src/services/graphql.ts +47 -47
- package/src/services/health.ts +226 -226
- package/src/services/locale.ts +156 -137
- package/src/services/migrations.ts +707 -0
- package/src/services/project.ts +160 -20
- package/src/services/projects.ts +1538 -1256
- package/src/services/proxy.ts +150 -0
- package/src/services/storage.ts +576 -571
- package/src/services/teams.ts +502 -501
- package/src/services/users.ts +1094 -1001
- package/src/services/vcs.ts +272 -0
- package/types/index.d.ts +4 -0
- package/types/models.d.ts +905 -114
- package/types/services/account.d.ts +62 -41
- package/types/services/assistant.d.ts +14 -0
- package/types/services/avatars.d.ts +7 -7
- package/types/services/console.d.ts +1 -1
- package/types/services/databases.d.ts +60 -54
- package/types/services/functions.d.ts +66 -31
- package/types/services/graphql.d.ts +2 -2
- package/types/services/health.d.ts +12 -12
- package/types/services/locale.d.ts +17 -7
- package/types/services/migrations.d.ts +185 -0
- package/types/services/project.d.ts +56 -1
- package/types/services/projects.d.ts +159 -79
- package/types/services/proxy.d.ts +59 -0
- package/types/services/storage.d.ts +18 -17
- package/types/services/teams.d.ts +17 -16
- package/types/services/users.d.ts +65 -27
- 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,687 @@ 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
|
+
let path = '/storage/buckets';
|
|
26
|
+
let 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
|
-
}
|
|
32
|
+
if (typeof search !== 'undefined') {
|
|
33
|
+
payload['search'] = search;
|
|
34
|
+
}
|
|
68
35
|
|
|
69
|
-
|
|
70
|
-
|
|
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);
|
|
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
|
+
}
|
|
71
64
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
if (typeof name === 'undefined') {
|
|
66
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
67
|
+
}
|
|
75
68
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
69
|
+
let path = '/storage/buckets';
|
|
70
|
+
let payload: Payload = {};
|
|
79
71
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
if (typeof bucketId !== 'undefined') {
|
|
73
|
+
payload['bucketId'] = bucketId;
|
|
74
|
+
}
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
if (typeof name !== 'undefined') {
|
|
77
|
+
payload['name'] = name;
|
|
78
|
+
}
|
|
87
79
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
if (typeof permissions !== 'undefined') {
|
|
81
|
+
payload['permissions'] = permissions;
|
|
82
|
+
}
|
|
91
83
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
if (typeof fileSecurity !== 'undefined') {
|
|
85
|
+
payload['fileSecurity'] = fileSecurity;
|
|
86
|
+
}
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
if (typeof enabled !== 'undefined') {
|
|
89
|
+
payload['enabled'] = enabled;
|
|
90
|
+
}
|
|
99
91
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
if (typeof maximumFileSize !== 'undefined') {
|
|
93
|
+
payload['maximumFileSize'] = maximumFileSize;
|
|
94
|
+
}
|
|
103
95
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
if (typeof allowedFileExtensions !== 'undefined') {
|
|
97
|
+
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
98
|
+
}
|
|
107
99
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
if (typeof compression !== 'undefined') {
|
|
101
|
+
payload['compression'] = compression;
|
|
102
|
+
}
|
|
111
103
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
'content-type': 'application/json',
|
|
115
|
-
}, payload);
|
|
104
|
+
if (typeof encryption !== 'undefined') {
|
|
105
|
+
payload['encryption'] = encryption;
|
|
116
106
|
}
|
|
117
107
|
|
|
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
|
-
}
|
|
108
|
+
if (typeof antivirus !== 'undefined') {
|
|
109
|
+
payload['antivirus'] = antivirus;
|
|
110
|
+
}
|
|
132
111
|
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
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
|
+
}
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
134
|
+
let payload: Payload = {};
|
|
135
|
+
|
|
136
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
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"');
|
|
140
163
|
}
|
|
141
164
|
|
|
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
|
-
}
|
|
165
|
+
if (typeof name === 'undefined') {
|
|
166
|
+
throw new AppwriteException('Missing required parameter: "name"');
|
|
167
|
+
}
|
|
164
168
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
169
|
+
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
170
|
+
let payload: Payload = {};
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
if (typeof name !== 'undefined') {
|
|
173
|
+
payload['name'] = name;
|
|
174
|
+
}
|
|
171
175
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
if (typeof permissions !== 'undefined') {
|
|
177
|
+
payload['permissions'] = permissions;
|
|
178
|
+
}
|
|
175
179
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
180
|
+
if (typeof fileSecurity !== 'undefined') {
|
|
181
|
+
payload['fileSecurity'] = fileSecurity;
|
|
182
|
+
}
|
|
179
183
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
if (typeof enabled !== 'undefined') {
|
|
185
|
+
payload['enabled'] = enabled;
|
|
186
|
+
}
|
|
183
187
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
188
|
+
if (typeof maximumFileSize !== 'undefined') {
|
|
189
|
+
payload['maximumFileSize'] = maximumFileSize;
|
|
190
|
+
}
|
|
187
191
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
if (typeof allowedFileExtensions !== 'undefined') {
|
|
193
|
+
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
194
|
+
}
|
|
191
195
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
if (typeof compression !== 'undefined') {
|
|
197
|
+
payload['compression'] = compression;
|
|
198
|
+
}
|
|
195
199
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
if (typeof encryption !== 'undefined') {
|
|
201
|
+
payload['encryption'] = encryption;
|
|
202
|
+
}
|
|
199
203
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
if (typeof antivirus !== 'undefined') {
|
|
205
|
+
payload['antivirus'] = antivirus;
|
|
206
|
+
}
|
|
203
207
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
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
|
+
}
|
|
207
227
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
228
|
+
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId);
|
|
229
|
+
let payload: Payload = {};
|
|
230
|
+
|
|
231
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
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"');
|
|
212
252
|
}
|
|
213
253
|
|
|
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
|
-
}
|
|
254
|
+
let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
255
|
+
let payload: Payload = {};
|
|
227
256
|
|
|
228
|
-
|
|
229
|
-
|
|
257
|
+
if (typeof queries !== 'undefined') {
|
|
258
|
+
payload['queries'] = queries;
|
|
259
|
+
}
|
|
230
260
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
'content-type': 'application/json',
|
|
234
|
-
}, payload);
|
|
261
|
+
if (typeof search !== 'undefined') {
|
|
262
|
+
payload['search'] = search;
|
|
235
263
|
}
|
|
236
264
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
265
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
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](/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
|
+
}
|
|
253
304
|
|
|
254
|
-
|
|
255
|
-
|
|
305
|
+
if (typeof fileId === 'undefined') {
|
|
306
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
307
|
+
}
|
|
256
308
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
309
|
+
if (typeof file === 'undefined') {
|
|
310
|
+
throw new AppwriteException('Missing required parameter: "file"');
|
|
311
|
+
}
|
|
260
312
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
313
|
+
let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId);
|
|
314
|
+
let payload: Payload = {};
|
|
264
315
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
'content-type': 'application/json',
|
|
268
|
-
}, payload);
|
|
316
|
+
if (typeof fileId !== 'undefined') {
|
|
317
|
+
payload['fileId'] = fileId;
|
|
269
318
|
}
|
|
270
319
|
|
|
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
|
-
}
|
|
320
|
+
if (typeof file !== 'undefined') {
|
|
321
|
+
payload['file'] = file;
|
|
322
|
+
}
|
|
304
323
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
324
|
+
if (typeof permissions !== 'undefined') {
|
|
325
|
+
payload['permissions'] = permissions;
|
|
326
|
+
}
|
|
308
327
|
|
|
309
|
-
|
|
310
|
-
throw new AppwriteException('Missing required parameter: "file"');
|
|
311
|
-
}
|
|
328
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
312
329
|
|
|
313
|
-
|
|
314
|
-
|
|
330
|
+
if(!(file instanceof File)) {
|
|
331
|
+
throw new AppwriteException('Parameter "file" has to be a File.');
|
|
332
|
+
}
|
|
315
333
|
|
|
316
|
-
|
|
317
|
-
payload['fileId'] = fileId;
|
|
318
|
-
}
|
|
334
|
+
const size = file.size;
|
|
319
335
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
336
|
+
if (size <= Service.CHUNK_SIZE) {
|
|
337
|
+
return await this.client.call('post', uri, {
|
|
323
338
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
339
|
+
'content-type': 'multipart/form-data',
|
|
340
|
+
}, payload);
|
|
341
|
+
}
|
|
342
|
+
let id = undefined;
|
|
343
|
+
let response = undefined;
|
|
327
344
|
|
|
328
|
-
|
|
345
|
+
const headers: { [header: string]: string } = {
|
|
346
|
+
'content-type': 'multipart/form-data',
|
|
347
|
+
}
|
|
329
348
|
|
|
330
|
-
|
|
331
|
-
|
|
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) {
|
|
332
356
|
}
|
|
357
|
+
}
|
|
333
358
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return await this.client.call('post', uri, {
|
|
338
|
-
|
|
339
|
-
'content-type': 'multipart/form-data',
|
|
340
|
-
}, payload);
|
|
341
|
-
}
|
|
342
|
-
let id = undefined;
|
|
343
|
-
let response = undefined;
|
|
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);
|
|
344
362
|
|
|
345
|
-
|
|
346
|
-
'content-type': 'multipart/form-data',
|
|
347
|
-
}
|
|
363
|
+
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size
|
|
348
364
|
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
}
|
|
365
|
+
if (id) {
|
|
366
|
+
headers['x-appwrite-id'] = id;
|
|
357
367
|
}
|
|
358
368
|
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
}
|
|
369
|
+
const stream = file.slice(start, end + 1);
|
|
370
|
+
payload['file'] = new File([stream], file.name);
|
|
368
371
|
|
|
369
|
-
|
|
370
|
-
payload['file'] = new File([stream], file.name);
|
|
372
|
+
response = await this.client.call('post', uri, headers, payload);
|
|
371
373
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (!id) {
|
|
375
|
-
id = response['$id'];
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (onProgress) {
|
|
379
|
-
onProgress({
|
|
380
|
-
$id: response.$id,
|
|
381
|
-
progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
|
|
382
|
-
sizeUploaded: end,
|
|
383
|
-
chunksTotal: response.chunksTotal,
|
|
384
|
-
chunksUploaded: response.chunksUploaded
|
|
385
|
-
});
|
|
386
|
-
}
|
|
374
|
+
if (!id) {
|
|
375
|
+
id = response['$id'];
|
|
387
376
|
}
|
|
388
377
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
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"');
|
|
378
|
+
if (onProgress) {
|
|
379
|
+
onProgress({
|
|
380
|
+
$id: response.$id,
|
|
381
|
+
progress: Math.min((counter + 1) * Service.CHUNK_SIZE - 1, size) / size * 100,
|
|
382
|
+
sizeUploaded: end,
|
|
383
|
+
chunksTotal: response.chunksTotal,
|
|
384
|
+
chunksUploaded: response.chunksUploaded
|
|
385
|
+
});
|
|
406
386
|
}
|
|
407
|
-
|
|
408
|
-
if (typeof fileId === 'undefined') {
|
|
409
|
-
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
413
|
-
let payload: Payload = {};
|
|
414
|
-
|
|
415
|
-
const uri = new URL(this.client.config.endpoint + path);
|
|
416
|
-
return await this.client.call('get', uri, {
|
|
417
|
-
'content-type': 'application/json',
|
|
418
|
-
}, payload);
|
|
419
387
|
}
|
|
420
388
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
440
|
-
}
|
|
389
|
+
return response;
|
|
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
|
+
}
|
|
441
407
|
|
|
442
|
-
|
|
443
|
-
|
|
408
|
+
if (typeof fileId === 'undefined') {
|
|
409
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
410
|
+
}
|
|
444
411
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
412
|
+
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
413
|
+
let payload: Payload = {};
|
|
414
|
+
|
|
415
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
416
|
+
return await this.client.call('get', uri, {
|
|
417
|
+
'content-type': 'application/json',
|
|
418
|
+
}, payload);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Update File
|
|
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} name
|
|
430
|
+
* @param {string[]} permissions
|
|
431
|
+
* @throws {AppwriteException}
|
|
432
|
+
* @returns {Promise}
|
|
433
|
+
*/
|
|
434
|
+
async updateFile(bucketId: string, fileId: string, name?: string, permissions?: string[]): Promise<Models.File> {
|
|
435
|
+
if (typeof bucketId === 'undefined') {
|
|
436
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
437
|
+
}
|
|
448
438
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
'content-type': 'application/json',
|
|
452
|
-
}, payload);
|
|
439
|
+
if (typeof fileId === 'undefined') {
|
|
440
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
453
441
|
}
|
|
454
442
|
|
|
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
|
-
}
|
|
443
|
+
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
444
|
+
let payload: Payload = {};
|
|
470
445
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
446
|
+
if (typeof name !== 'undefined') {
|
|
447
|
+
payload['name'] = name;
|
|
448
|
+
}
|
|
474
449
|
|
|
475
|
-
|
|
476
|
-
|
|
450
|
+
if (typeof permissions !== 'undefined') {
|
|
451
|
+
payload['permissions'] = permissions;
|
|
452
|
+
}
|
|
477
453
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
454
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
455
|
+
return await this.client.call('put', uri, {
|
|
456
|
+
'content-type': 'application/json',
|
|
457
|
+
}, payload);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Delete File
|
|
462
|
+
*
|
|
463
|
+
* Delete a file by its unique ID. Only users with write permissions have
|
|
464
|
+
* access to delete this resource.
|
|
465
|
+
*
|
|
466
|
+
* @param {string} bucketId
|
|
467
|
+
* @param {string} fileId
|
|
468
|
+
* @throws {AppwriteException}
|
|
469
|
+
* @returns {Promise}
|
|
470
|
+
*/
|
|
471
|
+
async deleteFile(bucketId: string, fileId: string): Promise<{}> {
|
|
472
|
+
if (typeof bucketId === 'undefined') {
|
|
473
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
482
474
|
}
|
|
483
475
|
|
|
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
|
-
}
|
|
476
|
+
if (typeof fileId === 'undefined') {
|
|
477
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
478
|
+
}
|
|
500
479
|
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
480
|
+
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
481
|
+
let payload: Payload = {};
|
|
482
|
+
|
|
483
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
484
|
+
return await this.client.call('delete', uri, {
|
|
485
|
+
'content-type': 'application/json',
|
|
486
|
+
}, payload);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Get File for Download
|
|
491
|
+
*
|
|
492
|
+
* Get a file content by its unique ID. The endpoint response return with a
|
|
493
|
+
* 'Content-Disposition: attachment' header that tells the browser to start
|
|
494
|
+
* downloading the file to user downloads directory.
|
|
495
|
+
*
|
|
496
|
+
* @param {string} bucketId
|
|
497
|
+
* @param {string} fileId
|
|
498
|
+
* @throws {AppwriteException}
|
|
499
|
+
* @returns {URL}
|
|
500
|
+
*/
|
|
501
|
+
getFileDownload(bucketId: string, fileId: string): URL {
|
|
502
|
+
if (typeof bucketId === 'undefined') {
|
|
503
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
504
|
+
}
|
|
504
505
|
|
|
505
|
-
|
|
506
|
-
|
|
506
|
+
if (typeof fileId === 'undefined') {
|
|
507
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
508
|
+
}
|
|
507
509
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
+
let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
511
|
+
let payload: Payload = {};
|
|
510
512
|
|
|
513
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
514
|
+
payload['project'] = this.client.config.project;
|
|
511
515
|
|
|
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
516
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
517
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
518
|
+
uri.searchParams.append(key, value);
|
|
519
|
+
}
|
|
520
|
+
return uri;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Get File Preview
|
|
525
|
+
*
|
|
526
|
+
* Get a file preview image. Currently, this method supports preview for image
|
|
527
|
+
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
528
|
+
* and spreadsheets, will return the file icon image. You can also pass query
|
|
529
|
+
* string arguments for cutting and resizing your preview image. Preview is
|
|
530
|
+
* supported only for image files smaller than 10MB.
|
|
531
|
+
*
|
|
532
|
+
* @param {string} bucketId
|
|
533
|
+
* @param {string} fileId
|
|
534
|
+
* @param {number} width
|
|
535
|
+
* @param {number} height
|
|
536
|
+
* @param {string} gravity
|
|
537
|
+
* @param {number} quality
|
|
538
|
+
* @param {number} borderWidth
|
|
539
|
+
* @param {string} borderColor
|
|
540
|
+
* @param {number} borderRadius
|
|
541
|
+
* @param {number} opacity
|
|
542
|
+
* @param {number} rotation
|
|
543
|
+
* @param {string} background
|
|
544
|
+
* @param {string} output
|
|
545
|
+
* @throws {AppwriteException}
|
|
546
|
+
* @returns {URL}
|
|
547
|
+
*/
|
|
548
|
+
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 {
|
|
549
|
+
if (typeof bucketId === 'undefined') {
|
|
550
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
551
|
+
}
|
|
551
552
|
|
|
552
|
-
|
|
553
|
-
|
|
553
|
+
if (typeof fileId === 'undefined') {
|
|
554
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
555
|
+
}
|
|
554
556
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}
|
|
557
|
+
let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
558
|
+
let payload: Payload = {};
|
|
558
559
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
560
|
+
if (typeof width !== 'undefined') {
|
|
561
|
+
payload['width'] = width;
|
|
562
|
+
}
|
|
562
563
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
if (typeof height !== 'undefined') {
|
|
565
|
+
payload['height'] = height;
|
|
566
|
+
}
|
|
566
567
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
568
|
+
if (typeof gravity !== 'undefined') {
|
|
569
|
+
payload['gravity'] = gravity;
|
|
570
|
+
}
|
|
570
571
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
572
|
+
if (typeof quality !== 'undefined') {
|
|
573
|
+
payload['quality'] = quality;
|
|
574
|
+
}
|
|
574
575
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
if (typeof borderWidth !== 'undefined') {
|
|
577
|
+
payload['borderWidth'] = borderWidth;
|
|
578
|
+
}
|
|
578
579
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
580
|
+
if (typeof borderColor !== 'undefined') {
|
|
581
|
+
payload['borderColor'] = borderColor;
|
|
582
|
+
}
|
|
582
583
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
584
|
+
if (typeof borderRadius !== 'undefined') {
|
|
585
|
+
payload['borderRadius'] = borderRadius;
|
|
586
|
+
}
|
|
586
587
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
588
|
+
if (typeof opacity !== 'undefined') {
|
|
589
|
+
payload['opacity'] = opacity;
|
|
590
|
+
}
|
|
590
591
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
592
|
+
if (typeof rotation !== 'undefined') {
|
|
593
|
+
payload['rotation'] = rotation;
|
|
594
|
+
}
|
|
594
595
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
596
|
+
if (typeof background !== 'undefined') {
|
|
597
|
+
payload['background'] = background;
|
|
598
|
+
}
|
|
598
599
|
|
|
599
|
-
|
|
600
|
-
payload['
|
|
600
|
+
if (typeof output !== 'undefined') {
|
|
601
|
+
payload['output'] = output;
|
|
602
|
+
}
|
|
601
603
|
|
|
604
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
605
|
+
payload['project'] = this.client.config.project;
|
|
602
606
|
|
|
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
607
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
608
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
609
|
+
uri.searchParams.append(key, value);
|
|
610
|
+
}
|
|
611
|
+
return uri;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Get File for View
|
|
616
|
+
*
|
|
617
|
+
* Get a file content by its unique ID. This endpoint is similar to the
|
|
618
|
+
* download method but returns with no 'Content-Disposition: attachment'
|
|
619
|
+
* header.
|
|
620
|
+
*
|
|
621
|
+
* @param {string} bucketId
|
|
622
|
+
* @param {string} fileId
|
|
623
|
+
* @throws {AppwriteException}
|
|
624
|
+
* @returns {URL}
|
|
625
|
+
*/
|
|
626
|
+
getFileView(bucketId: string, fileId: string): URL {
|
|
627
|
+
if (typeof bucketId === 'undefined') {
|
|
628
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
629
|
+
}
|
|
629
630
|
|
|
630
|
-
|
|
631
|
-
|
|
631
|
+
if (typeof fileId === 'undefined') {
|
|
632
|
+
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
633
|
+
}
|
|
632
634
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
+
let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
636
|
+
let payload: Payload = {};
|
|
635
637
|
|
|
638
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
639
|
+
payload['project'] = this.client.config.project;
|
|
636
640
|
|
|
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
641
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
642
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
643
|
+
uri.searchParams.append(key, value);
|
|
644
|
+
}
|
|
645
|
+
return uri;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Get usage stats for storage
|
|
650
|
+
*
|
|
651
|
+
*
|
|
652
|
+
* @param {string} range
|
|
653
|
+
* @throws {AppwriteException}
|
|
654
|
+
* @returns {Promise}
|
|
655
|
+
*/
|
|
656
|
+
async getUsage(range?: string): Promise<Models.UsageStorage> {
|
|
657
|
+
let path = '/storage/usage';
|
|
658
|
+
let payload: Payload = {};
|
|
659
|
+
|
|
660
|
+
if (typeof range !== 'undefined') {
|
|
661
|
+
payload['range'] = range;
|
|
663
662
|
}
|
|
664
663
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
664
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
665
|
+
return await this.client.call('get', uri, {
|
|
666
|
+
'content-type': 'application/json',
|
|
667
|
+
}, payload);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Get usage stats for a storage bucket
|
|
672
|
+
*
|
|
673
|
+
*
|
|
674
|
+
* @param {string} bucketId
|
|
675
|
+
* @param {string} range
|
|
676
|
+
* @throws {AppwriteException}
|
|
677
|
+
* @returns {Promise}
|
|
678
|
+
*/
|
|
679
|
+
async getBucketUsage(bucketId: string, range?: string): Promise<Models.UsageBuckets> {
|
|
680
|
+
if (typeof bucketId === 'undefined') {
|
|
681
|
+
throw new AppwriteException('Missing required parameter: "bucketId"');
|
|
682
|
+
}
|
|
681
683
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
684
|
+
let path = '/storage/{bucketId}/usage'.replace('{bucketId}', bucketId);
|
|
685
|
+
let payload: Payload = {};
|
|
685
686
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
'content-type': 'application/json',
|
|
689
|
-
}, payload);
|
|
687
|
+
if (typeof range !== 'undefined') {
|
|
688
|
+
payload['range'] = range;
|
|
690
689
|
}
|
|
690
|
+
|
|
691
|
+
const uri = new URL(this.client.config.endpoint + path);
|
|
692
|
+
return await this.client.call('get', uri, {
|
|
693
|
+
'content-type': 'application/json',
|
|
694
|
+
}, payload);
|
|
695
|
+
}
|
|
691
696
|
};
|