react-native-appwrite 0.9.2 → 0.10.1
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/.github/workflows/publish.yml +1 -1
- package/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/cjs/sdk.js +401 -20
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +401 -20
- package/dist/esm/sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -2
- package/src/enums/image-format.ts +1 -0
- package/src/services/avatars.ts +331 -20
- package/src/services/databases.ts +4 -0
- package/src/services/storage.ts +155 -8
- package/types/client.d.ts +1 -1
- package/types/enums/image-format.d.ts +2 -1
- package/types/services/avatars.d.ts +136 -7
- package/types/services/databases.d.ts +4 -0
- package/types/services/storage.d.ts +52 -3
package/dist/esm/sdk.js
CHANGED
|
@@ -78,7 +78,7 @@ class Client {
|
|
|
78
78
|
'x-sdk-name': 'React Native',
|
|
79
79
|
'x-sdk-platform': 'client',
|
|
80
80
|
'x-sdk-language': 'reactnative',
|
|
81
|
-
'x-sdk-version': '0.
|
|
81
|
+
'x-sdk-version': '0.10.1',
|
|
82
82
|
'X-Appwrite-Response-Format': '1.7.0',
|
|
83
83
|
};
|
|
84
84
|
this.realtime = {
|
|
@@ -370,7 +370,7 @@ class Client {
|
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
372
|
call(method_1, url_1) {
|
|
373
|
-
return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}) {
|
|
373
|
+
return __awaiter(this, arguments, void 0, function* (method, url, headers = {}, params = {}, responseType = 'json') {
|
|
374
374
|
var _a, _b;
|
|
375
375
|
method = method.toUpperCase();
|
|
376
376
|
headers = Object.assign({}, this.headers, headers);
|
|
@@ -419,6 +419,9 @@ class Client {
|
|
|
419
419
|
if ((_a = response.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.includes('application/json')) {
|
|
420
420
|
data = yield response.json();
|
|
421
421
|
}
|
|
422
|
+
else if (responseType === 'arrayBuffer') {
|
|
423
|
+
data = yield response.arrayBuffer();
|
|
424
|
+
}
|
|
422
425
|
else {
|
|
423
426
|
data = {
|
|
424
427
|
message: yield response.text()
|
|
@@ -1705,7 +1708,7 @@ class Avatars extends Service {
|
|
|
1705
1708
|
* @param {number} height
|
|
1706
1709
|
* @param {number} quality
|
|
1707
1710
|
* @throws {AppwriteException}
|
|
1708
|
-
* @returns {
|
|
1711
|
+
* @returns {ArrayBuffer}
|
|
1709
1712
|
*/
|
|
1710
1713
|
getBrowser(code, width, height, quality) {
|
|
1711
1714
|
if (typeof code === 'undefined') {
|
|
@@ -1727,7 +1730,7 @@ class Avatars extends Service {
|
|
|
1727
1730
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1728
1731
|
uri.searchParams.append(key, value);
|
|
1729
1732
|
}
|
|
1730
|
-
return uri;
|
|
1733
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1731
1734
|
}
|
|
1732
1735
|
/**
|
|
1733
1736
|
* The credit card endpoint will return you the icon of the credit card
|
|
@@ -1745,7 +1748,7 @@ class Avatars extends Service {
|
|
|
1745
1748
|
* @param {number} height
|
|
1746
1749
|
* @param {number} quality
|
|
1747
1750
|
* @throws {AppwriteException}
|
|
1748
|
-
* @returns {
|
|
1751
|
+
* @returns {ArrayBuffer}
|
|
1749
1752
|
*/
|
|
1750
1753
|
getCreditCard(code, width, height, quality) {
|
|
1751
1754
|
if (typeof code === 'undefined') {
|
|
@@ -1767,7 +1770,7 @@ class Avatars extends Service {
|
|
|
1767
1770
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1768
1771
|
uri.searchParams.append(key, value);
|
|
1769
1772
|
}
|
|
1770
|
-
return uri;
|
|
1773
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1771
1774
|
}
|
|
1772
1775
|
/**
|
|
1773
1776
|
* Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
|
|
@@ -1777,7 +1780,7 @@ class Avatars extends Service {
|
|
|
1777
1780
|
*
|
|
1778
1781
|
* @param {string} url
|
|
1779
1782
|
* @throws {AppwriteException}
|
|
1780
|
-
* @returns {
|
|
1783
|
+
* @returns {ArrayBuffer}
|
|
1781
1784
|
*/
|
|
1782
1785
|
getFavicon(url) {
|
|
1783
1786
|
if (typeof url === 'undefined') {
|
|
@@ -1793,7 +1796,7 @@ class Avatars extends Service {
|
|
|
1793
1796
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1794
1797
|
uri.searchParams.append(key, value);
|
|
1795
1798
|
}
|
|
1796
|
-
return uri;
|
|
1799
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1797
1800
|
}
|
|
1798
1801
|
/**
|
|
1799
1802
|
* You can use this endpoint to show different country flags icons to your
|
|
@@ -1812,7 +1815,7 @@ class Avatars extends Service {
|
|
|
1812
1815
|
* @param {number} height
|
|
1813
1816
|
* @param {number} quality
|
|
1814
1817
|
* @throws {AppwriteException}
|
|
1815
|
-
* @returns {
|
|
1818
|
+
* @returns {ArrayBuffer}
|
|
1816
1819
|
*/
|
|
1817
1820
|
getFlag(code, width, height, quality) {
|
|
1818
1821
|
if (typeof code === 'undefined') {
|
|
@@ -1834,7 +1837,7 @@ class Avatars extends Service {
|
|
|
1834
1837
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1835
1838
|
uri.searchParams.append(key, value);
|
|
1836
1839
|
}
|
|
1837
|
-
return uri;
|
|
1840
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1838
1841
|
}
|
|
1839
1842
|
/**
|
|
1840
1843
|
* Use this endpoint to fetch a remote image URL and crop it to any image size
|
|
@@ -1853,7 +1856,7 @@ class Avatars extends Service {
|
|
|
1853
1856
|
* @param {number} width
|
|
1854
1857
|
* @param {number} height
|
|
1855
1858
|
* @throws {AppwriteException}
|
|
1856
|
-
* @returns {
|
|
1859
|
+
* @returns {ArrayBuffer}
|
|
1857
1860
|
*/
|
|
1858
1861
|
getImage(url, width, height) {
|
|
1859
1862
|
if (typeof url === 'undefined') {
|
|
@@ -1875,7 +1878,7 @@ class Avatars extends Service {
|
|
|
1875
1878
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1876
1879
|
uri.searchParams.append(key, value);
|
|
1877
1880
|
}
|
|
1878
|
-
return uri;
|
|
1881
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1879
1882
|
}
|
|
1880
1883
|
/**
|
|
1881
1884
|
* Use this endpoint to show your user initials avatar icon on your website or
|
|
@@ -1900,7 +1903,7 @@ class Avatars extends Service {
|
|
|
1900
1903
|
* @param {number} height
|
|
1901
1904
|
* @param {string} background
|
|
1902
1905
|
* @throws {AppwriteException}
|
|
1903
|
-
* @returns {
|
|
1906
|
+
* @returns {ArrayBuffer}
|
|
1904
1907
|
*/
|
|
1905
1908
|
getInitials(name, width, height, background) {
|
|
1906
1909
|
const apiPath = '/avatars/initials';
|
|
@@ -1922,7 +1925,7 @@ class Avatars extends Service {
|
|
|
1922
1925
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1923
1926
|
uri.searchParams.append(key, value);
|
|
1924
1927
|
}
|
|
1925
|
-
return uri;
|
|
1928
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1926
1929
|
}
|
|
1927
1930
|
/**
|
|
1928
1931
|
* Converts a given plain text to a QR code image. You can use the query
|
|
@@ -1934,12 +1937,267 @@ class Avatars extends Service {
|
|
|
1934
1937
|
* @param {number} margin
|
|
1935
1938
|
* @param {boolean} download
|
|
1936
1939
|
* @throws {AppwriteException}
|
|
1937
|
-
* @returns {
|
|
1940
|
+
* @returns {ArrayBuffer}
|
|
1938
1941
|
*/
|
|
1939
1942
|
getQR(text, size, margin, download) {
|
|
1940
1943
|
if (typeof text === 'undefined') {
|
|
1941
1944
|
throw new AppwriteException('Missing required parameter: "text"');
|
|
1942
1945
|
}
|
|
1946
|
+
const apiPath = '/avatars/qr';
|
|
1947
|
+
const payload = {};
|
|
1948
|
+
if (typeof text !== 'undefined') {
|
|
1949
|
+
payload['text'] = text;
|
|
1950
|
+
}
|
|
1951
|
+
if (typeof size !== 'undefined') {
|
|
1952
|
+
payload['size'] = size;
|
|
1953
|
+
}
|
|
1954
|
+
if (typeof margin !== 'undefined') {
|
|
1955
|
+
payload['margin'] = margin;
|
|
1956
|
+
}
|
|
1957
|
+
if (typeof download !== 'undefined') {
|
|
1958
|
+
payload['download'] = download;
|
|
1959
|
+
}
|
|
1960
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1961
|
+
payload['project'] = this.client.config.project;
|
|
1962
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
1963
|
+
uri.searchParams.append(key, value);
|
|
1964
|
+
}
|
|
1965
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* You can use this endpoint to show different browser icons to your users.
|
|
1969
|
+
* The code argument receives the browser code as it appears in your user [GET
|
|
1970
|
+
* /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions)
|
|
1971
|
+
* endpoint. Use width, height and quality arguments to change the output
|
|
1972
|
+
* settings.
|
|
1973
|
+
*
|
|
1974
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
1975
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
1976
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
1977
|
+
* of image returned is 100x100px.
|
|
1978
|
+
*
|
|
1979
|
+
* @param {Browser} code
|
|
1980
|
+
* @param {number} width
|
|
1981
|
+
* @param {number} height
|
|
1982
|
+
* @param {number} quality
|
|
1983
|
+
* @throws {AppwriteException}
|
|
1984
|
+
* @returns {URL}
|
|
1985
|
+
*/
|
|
1986
|
+
getBrowserURL(code, width, height, quality) {
|
|
1987
|
+
const apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
|
|
1988
|
+
const payload = {};
|
|
1989
|
+
if (typeof width !== 'undefined') {
|
|
1990
|
+
payload['width'] = width;
|
|
1991
|
+
}
|
|
1992
|
+
if (typeof height !== 'undefined') {
|
|
1993
|
+
payload['height'] = height;
|
|
1994
|
+
}
|
|
1995
|
+
if (typeof quality !== 'undefined') {
|
|
1996
|
+
payload['quality'] = quality;
|
|
1997
|
+
}
|
|
1998
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
1999
|
+
payload['project'] = this.client.config.project;
|
|
2000
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2001
|
+
uri.searchParams.append(key, value);
|
|
2002
|
+
}
|
|
2003
|
+
return uri;
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* The credit card endpoint will return you the icon of the credit card
|
|
2007
|
+
* provider you need. Use width, height and quality arguments to change the
|
|
2008
|
+
* output settings.
|
|
2009
|
+
*
|
|
2010
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2011
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2012
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2013
|
+
* of image returned is 100x100px.
|
|
2014
|
+
*
|
|
2015
|
+
*
|
|
2016
|
+
* @param {CreditCard} code
|
|
2017
|
+
* @param {number} width
|
|
2018
|
+
* @param {number} height
|
|
2019
|
+
* @param {number} quality
|
|
2020
|
+
* @throws {AppwriteException}
|
|
2021
|
+
* @returns {URL}
|
|
2022
|
+
*/
|
|
2023
|
+
getCreditCardURL(code, width, height, quality) {
|
|
2024
|
+
const apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
|
|
2025
|
+
const payload = {};
|
|
2026
|
+
if (typeof width !== 'undefined') {
|
|
2027
|
+
payload['width'] = width;
|
|
2028
|
+
}
|
|
2029
|
+
if (typeof height !== 'undefined') {
|
|
2030
|
+
payload['height'] = height;
|
|
2031
|
+
}
|
|
2032
|
+
if (typeof quality !== 'undefined') {
|
|
2033
|
+
payload['quality'] = quality;
|
|
2034
|
+
}
|
|
2035
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2036
|
+
payload['project'] = this.client.config.project;
|
|
2037
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2038
|
+
uri.searchParams.append(key, value);
|
|
2039
|
+
}
|
|
2040
|
+
return uri;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
|
|
2044
|
+
* website URL.
|
|
2045
|
+
*
|
|
2046
|
+
* This endpoint does not follow HTTP redirects.
|
|
2047
|
+
*
|
|
2048
|
+
* @param {string} url
|
|
2049
|
+
* @throws {AppwriteException}
|
|
2050
|
+
* @returns {URL}
|
|
2051
|
+
*/
|
|
2052
|
+
getFaviconURL(url) {
|
|
2053
|
+
const apiPath = '/avatars/favicon';
|
|
2054
|
+
const payload = {};
|
|
2055
|
+
if (typeof url !== 'undefined') {
|
|
2056
|
+
payload['url'] = url;
|
|
2057
|
+
}
|
|
2058
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2059
|
+
payload['project'] = this.client.config.project;
|
|
2060
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2061
|
+
uri.searchParams.append(key, value);
|
|
2062
|
+
}
|
|
2063
|
+
return uri;
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* You can use this endpoint to show different country flags icons to your
|
|
2067
|
+
* users. The code argument receives the 2 letter country code. Use width,
|
|
2068
|
+
* height and quality arguments to change the output settings. Country codes
|
|
2069
|
+
* follow the [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard.
|
|
2070
|
+
*
|
|
2071
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2072
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2073
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2074
|
+
* of image returned is 100x100px.
|
|
2075
|
+
*
|
|
2076
|
+
*
|
|
2077
|
+
* @param {Flag} code
|
|
2078
|
+
* @param {number} width
|
|
2079
|
+
* @param {number} height
|
|
2080
|
+
* @param {number} quality
|
|
2081
|
+
* @throws {AppwriteException}
|
|
2082
|
+
* @returns {URL}
|
|
2083
|
+
*/
|
|
2084
|
+
getFlagURL(code, width, height, quality) {
|
|
2085
|
+
const apiPath = '/avatars/flags/{code}'.replace('{code}', code);
|
|
2086
|
+
const payload = {};
|
|
2087
|
+
if (typeof width !== 'undefined') {
|
|
2088
|
+
payload['width'] = width;
|
|
2089
|
+
}
|
|
2090
|
+
if (typeof height !== 'undefined') {
|
|
2091
|
+
payload['height'] = height;
|
|
2092
|
+
}
|
|
2093
|
+
if (typeof quality !== 'undefined') {
|
|
2094
|
+
payload['quality'] = quality;
|
|
2095
|
+
}
|
|
2096
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2097
|
+
payload['project'] = this.client.config.project;
|
|
2098
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2099
|
+
uri.searchParams.append(key, value);
|
|
2100
|
+
}
|
|
2101
|
+
return uri;
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* Use this endpoint to fetch a remote image URL and crop it to any image size
|
|
2105
|
+
* you want. This endpoint is very useful if you need to crop and display
|
|
2106
|
+
* remote images in your app or in case you want to make sure a 3rd party
|
|
2107
|
+
* image is properly served using a TLS protocol.
|
|
2108
|
+
*
|
|
2109
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2110
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2111
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2112
|
+
* of image returned is 400x400px.
|
|
2113
|
+
*
|
|
2114
|
+
* This endpoint does not follow HTTP redirects.
|
|
2115
|
+
*
|
|
2116
|
+
* @param {string} url
|
|
2117
|
+
* @param {number} width
|
|
2118
|
+
* @param {number} height
|
|
2119
|
+
* @throws {AppwriteException}
|
|
2120
|
+
* @returns {URL}
|
|
2121
|
+
*/
|
|
2122
|
+
getImageURL(url, width, height) {
|
|
2123
|
+
const apiPath = '/avatars/image';
|
|
2124
|
+
const payload = {};
|
|
2125
|
+
if (typeof url !== 'undefined') {
|
|
2126
|
+
payload['url'] = url;
|
|
2127
|
+
}
|
|
2128
|
+
if (typeof width !== 'undefined') {
|
|
2129
|
+
payload['width'] = width;
|
|
2130
|
+
}
|
|
2131
|
+
if (typeof height !== 'undefined') {
|
|
2132
|
+
payload['height'] = height;
|
|
2133
|
+
}
|
|
2134
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2135
|
+
payload['project'] = this.client.config.project;
|
|
2136
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2137
|
+
uri.searchParams.append(key, value);
|
|
2138
|
+
}
|
|
2139
|
+
return uri;
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* Use this endpoint to show your user initials avatar icon on your website or
|
|
2143
|
+
* app. By default, this route will try to print your logged-in user name or
|
|
2144
|
+
* email initials. You can also overwrite the user name if you pass the 'name'
|
|
2145
|
+
* parameter. If no name is given and no user is logged, an empty avatar will
|
|
2146
|
+
* be returned.
|
|
2147
|
+
*
|
|
2148
|
+
* You can use the color and background params to change the avatar colors. By
|
|
2149
|
+
* default, a random theme will be selected. The random theme will persist for
|
|
2150
|
+
* the user's initials when reloading the same theme will always return for
|
|
2151
|
+
* the same initials.
|
|
2152
|
+
*
|
|
2153
|
+
* When one dimension is specified and the other is 0, the image is scaled
|
|
2154
|
+
* with preserved aspect ratio. If both dimensions are 0, the API provides an
|
|
2155
|
+
* image at source quality. If dimensions are not specified, the default size
|
|
2156
|
+
* of image returned is 100x100px.
|
|
2157
|
+
*
|
|
2158
|
+
*
|
|
2159
|
+
* @param {string} name
|
|
2160
|
+
* @param {number} width
|
|
2161
|
+
* @param {number} height
|
|
2162
|
+
* @param {string} background
|
|
2163
|
+
* @throws {AppwriteException}
|
|
2164
|
+
* @returns {URL}
|
|
2165
|
+
*/
|
|
2166
|
+
getInitialsURL(name, width, height, background) {
|
|
2167
|
+
const apiPath = '/avatars/initials';
|
|
2168
|
+
const payload = {};
|
|
2169
|
+
if (typeof name !== 'undefined') {
|
|
2170
|
+
payload['name'] = name;
|
|
2171
|
+
}
|
|
2172
|
+
if (typeof width !== 'undefined') {
|
|
2173
|
+
payload['width'] = width;
|
|
2174
|
+
}
|
|
2175
|
+
if (typeof height !== 'undefined') {
|
|
2176
|
+
payload['height'] = height;
|
|
2177
|
+
}
|
|
2178
|
+
if (typeof background !== 'undefined') {
|
|
2179
|
+
payload['background'] = background;
|
|
2180
|
+
}
|
|
2181
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
2182
|
+
payload['project'] = this.client.config.project;
|
|
2183
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2184
|
+
uri.searchParams.append(key, value);
|
|
2185
|
+
}
|
|
2186
|
+
return uri;
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Converts a given plain text to a QR code image. You can use the query
|
|
2190
|
+
* parameters to change the size and style of the resulting image.
|
|
2191
|
+
*
|
|
2192
|
+
*
|
|
2193
|
+
* @param {string} text
|
|
2194
|
+
* @param {number} size
|
|
2195
|
+
* @param {number} margin
|
|
2196
|
+
* @param {boolean} download
|
|
2197
|
+
* @throws {AppwriteException}
|
|
2198
|
+
* @returns {URL}
|
|
2199
|
+
*/
|
|
2200
|
+
getQRURL(text, size, margin, download) {
|
|
1943
2201
|
const apiPath = '/avatars/qr';
|
|
1944
2202
|
const payload = {};
|
|
1945
2203
|
if (typeof text !== 'undefined') {
|
|
@@ -2065,6 +2323,10 @@ class Databases extends Service {
|
|
|
2065
2323
|
return this.client.call('get', uri, {}, payload);
|
|
2066
2324
|
}
|
|
2067
2325
|
/**
|
|
2326
|
+
* **WARNING: Experimental Feature** - This endpoint is experimental and not
|
|
2327
|
+
* yet officially supported. It may be subject to breaking changes or removal
|
|
2328
|
+
* in future versions.
|
|
2329
|
+
*
|
|
2068
2330
|
* Create or update a Document. Before using this route, you should create a
|
|
2069
2331
|
* new collection resource using either a [server
|
|
2070
2332
|
* integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
|
|
@@ -2697,7 +2959,7 @@ class Storage extends Service {
|
|
|
2697
2959
|
* @param {string} fileId
|
|
2698
2960
|
* @param {string} token
|
|
2699
2961
|
* @throws {AppwriteException}
|
|
2700
|
-
* @returns {
|
|
2962
|
+
* @returns {ArrayBuffer}
|
|
2701
2963
|
*/
|
|
2702
2964
|
getFileDownload(bucketId, fileId, token) {
|
|
2703
2965
|
if (typeof bucketId === 'undefined') {
|
|
@@ -2716,7 +2978,7 @@ class Storage extends Service {
|
|
|
2716
2978
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2717
2979
|
uri.searchParams.append(key, value);
|
|
2718
2980
|
}
|
|
2719
|
-
return uri;
|
|
2981
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
2720
2982
|
}
|
|
2721
2983
|
/**
|
|
2722
2984
|
* Get a file preview image. Currently, this method supports preview for image
|
|
@@ -2740,7 +3002,7 @@ class Storage extends Service {
|
|
|
2740
3002
|
* @param {ImageFormat} output
|
|
2741
3003
|
* @param {string} token
|
|
2742
3004
|
* @throws {AppwriteException}
|
|
2743
|
-
* @returns {
|
|
3005
|
+
* @returns {ArrayBuffer}
|
|
2744
3006
|
*/
|
|
2745
3007
|
getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
|
|
2746
3008
|
if (typeof bucketId === 'undefined') {
|
|
@@ -2792,7 +3054,7 @@ class Storage extends Service {
|
|
|
2792
3054
|
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
2793
3055
|
uri.searchParams.append(key, value);
|
|
2794
3056
|
}
|
|
2795
|
-
return uri;
|
|
3057
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
2796
3058
|
}
|
|
2797
3059
|
/**
|
|
2798
3060
|
* Get a file content by its unique ID. This endpoint is similar to the
|
|
@@ -2803,7 +3065,7 @@ class Storage extends Service {
|
|
|
2803
3065
|
* @param {string} fileId
|
|
2804
3066
|
* @param {string} token
|
|
2805
3067
|
* @throws {AppwriteException}
|
|
2806
|
-
* @returns {
|
|
3068
|
+
* @returns {ArrayBuffer}
|
|
2807
3069
|
*/
|
|
2808
3070
|
getFileView(bucketId, fileId, token) {
|
|
2809
3071
|
if (typeof bucketId === 'undefined') {
|
|
@@ -2812,6 +3074,124 @@ class Storage extends Service {
|
|
|
2812
3074
|
if (typeof fileId === 'undefined') {
|
|
2813
3075
|
throw new AppwriteException('Missing required parameter: "fileId"');
|
|
2814
3076
|
}
|
|
3077
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
3078
|
+
const payload = {};
|
|
3079
|
+
if (typeof token !== 'undefined') {
|
|
3080
|
+
payload['token'] = token;
|
|
3081
|
+
}
|
|
3082
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
3083
|
+
payload['project'] = this.client.config.project;
|
|
3084
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
3085
|
+
uri.searchParams.append(key, value);
|
|
3086
|
+
}
|
|
3087
|
+
return this.client.call('get', uri, {}, payload, 'arrayBuffer');
|
|
3088
|
+
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Get a file content by its unique ID. The endpoint response return with a
|
|
3091
|
+
* 'Content-Disposition: attachment' header that tells the browser to start
|
|
3092
|
+
* downloading the file to user downloads directory.
|
|
3093
|
+
*
|
|
3094
|
+
* @param {string} bucketId
|
|
3095
|
+
* @param {string} fileId
|
|
3096
|
+
* @param {string} token
|
|
3097
|
+
* @throws {AppwriteException}
|
|
3098
|
+
* @returns {URL}
|
|
3099
|
+
*/
|
|
3100
|
+
getFileDownloadURL(bucketId, fileId, token) {
|
|
3101
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
3102
|
+
const payload = {};
|
|
3103
|
+
if (typeof token !== 'undefined') {
|
|
3104
|
+
payload['token'] = token;
|
|
3105
|
+
}
|
|
3106
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
3107
|
+
payload['project'] = this.client.config.project;
|
|
3108
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
3109
|
+
uri.searchParams.append(key, value);
|
|
3110
|
+
}
|
|
3111
|
+
return uri;
|
|
3112
|
+
}
|
|
3113
|
+
/**
|
|
3114
|
+
* Get a file preview image. Currently, this method supports preview for image
|
|
3115
|
+
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
|
3116
|
+
* and spreadsheets, will return the file icon image. You can also pass query
|
|
3117
|
+
* string arguments for cutting and resizing your preview image. Preview is
|
|
3118
|
+
* supported only for image files smaller than 10MB.
|
|
3119
|
+
*
|
|
3120
|
+
* @param {string} bucketId
|
|
3121
|
+
* @param {string} fileId
|
|
3122
|
+
* @param {number} width
|
|
3123
|
+
* @param {number} height
|
|
3124
|
+
* @param {ImageGravity} gravity
|
|
3125
|
+
* @param {number} quality
|
|
3126
|
+
* @param {number} borderWidth
|
|
3127
|
+
* @param {string} borderColor
|
|
3128
|
+
* @param {number} borderRadius
|
|
3129
|
+
* @param {number} opacity
|
|
3130
|
+
* @param {number} rotation
|
|
3131
|
+
* @param {string} background
|
|
3132
|
+
* @param {ImageFormat} output
|
|
3133
|
+
* @param {string} token
|
|
3134
|
+
* @throws {AppwriteException}
|
|
3135
|
+
* @returns {URL}
|
|
3136
|
+
*/
|
|
3137
|
+
getFilePreviewURL(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output, token) {
|
|
3138
|
+
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
3139
|
+
const payload = {};
|
|
3140
|
+
if (typeof width !== 'undefined') {
|
|
3141
|
+
payload['width'] = width;
|
|
3142
|
+
}
|
|
3143
|
+
if (typeof height !== 'undefined') {
|
|
3144
|
+
payload['height'] = height;
|
|
3145
|
+
}
|
|
3146
|
+
if (typeof gravity !== 'undefined') {
|
|
3147
|
+
payload['gravity'] = gravity;
|
|
3148
|
+
}
|
|
3149
|
+
if (typeof quality !== 'undefined') {
|
|
3150
|
+
payload['quality'] = quality;
|
|
3151
|
+
}
|
|
3152
|
+
if (typeof borderWidth !== 'undefined') {
|
|
3153
|
+
payload['borderWidth'] = borderWidth;
|
|
3154
|
+
}
|
|
3155
|
+
if (typeof borderColor !== 'undefined') {
|
|
3156
|
+
payload['borderColor'] = borderColor;
|
|
3157
|
+
}
|
|
3158
|
+
if (typeof borderRadius !== 'undefined') {
|
|
3159
|
+
payload['borderRadius'] = borderRadius;
|
|
3160
|
+
}
|
|
3161
|
+
if (typeof opacity !== 'undefined') {
|
|
3162
|
+
payload['opacity'] = opacity;
|
|
3163
|
+
}
|
|
3164
|
+
if (typeof rotation !== 'undefined') {
|
|
3165
|
+
payload['rotation'] = rotation;
|
|
3166
|
+
}
|
|
3167
|
+
if (typeof background !== 'undefined') {
|
|
3168
|
+
payload['background'] = background;
|
|
3169
|
+
}
|
|
3170
|
+
if (typeof output !== 'undefined') {
|
|
3171
|
+
payload['output'] = output;
|
|
3172
|
+
}
|
|
3173
|
+
if (typeof token !== 'undefined') {
|
|
3174
|
+
payload['token'] = token;
|
|
3175
|
+
}
|
|
3176
|
+
const uri = new URL(this.client.config.endpoint + apiPath);
|
|
3177
|
+
payload['project'] = this.client.config.project;
|
|
3178
|
+
for (const [key, value] of Object.entries(Service.flatten(payload))) {
|
|
3179
|
+
uri.searchParams.append(key, value);
|
|
3180
|
+
}
|
|
3181
|
+
return uri;
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Get a file content by its unique ID. This endpoint is similar to the
|
|
3185
|
+
* download method but returns with no 'Content-Disposition: attachment'
|
|
3186
|
+
* header.
|
|
3187
|
+
*
|
|
3188
|
+
* @param {string} bucketId
|
|
3189
|
+
* @param {string} fileId
|
|
3190
|
+
* @param {string} token
|
|
3191
|
+
* @throws {AppwriteException}
|
|
3192
|
+
* @returns {URL}
|
|
3193
|
+
*/
|
|
3194
|
+
getFileViewURL(bucketId, fileId, token) {
|
|
2815
3195
|
const apiPath = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
2816
3196
|
const payload = {};
|
|
2817
3197
|
if (typeof token !== 'undefined') {
|
|
@@ -3710,6 +4090,7 @@ var ImageFormat;
|
|
|
3710
4090
|
ImageFormat["Webp"] = "webp";
|
|
3711
4091
|
ImageFormat["Heic"] = "heic";
|
|
3712
4092
|
ImageFormat["Avif"] = "avif";
|
|
4093
|
+
ImageFormat["Gif"] = "gif";
|
|
3713
4094
|
})(ImageFormat || (ImageFormat = {}));
|
|
3714
4095
|
|
|
3715
4096
|
export { Account, AppwriteException, AuthenticationFactor, AuthenticatorType, Avatars, Browser, Client, CreditCard, Databases, ExecutionMethod, Flag, Functions, Graphql, ID, ImageFormat, ImageGravity, Locale, Messaging, OAuthProvider, Permission, Query, Role, Storage, Teams };
|