react-native-appwrite 0.2.0 → 0.2.2
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 +9 -5
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +9 -4
- package/dist/esm/sdk.js.map +1 -1
- package/package.json +4 -3
- package/src/client.ts +3 -3
- package/src/services/storage.ts +7 -2
package/dist/cjs/sdk.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var reactNative = require('react-native');
|
|
4
4
|
var FileSystem = require('expo-file-system');
|
|
5
5
|
|
|
6
6
|
function _interopNamespace(e) {
|
|
@@ -21,7 +21,6 @@ function _interopNamespace(e) {
|
|
|
21
21
|
return Object.freeze(n);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
var Device__namespace = /*#__PURE__*/_interopNamespace(Device);
|
|
25
24
|
var FileSystem__namespace = /*#__PURE__*/_interopNamespace(FileSystem);
|
|
26
25
|
|
|
27
26
|
/******************************************************************************
|
|
@@ -179,7 +178,7 @@ class Client {
|
|
|
179
178
|
// @ts-ignore
|
|
180
179
|
this.realtime.socket = new WebSocket(url, undefined, {
|
|
181
180
|
headers: {
|
|
182
|
-
Origin: `appwrite-${
|
|
181
|
+
Origin: `appwrite-${reactNative.Platform.OS}://${this.config.platform}`
|
|
183
182
|
}
|
|
184
183
|
});
|
|
185
184
|
this.realtime.socket.addEventListener('message', this.realtime.onMessage);
|
|
@@ -368,7 +367,7 @@ class Client {
|
|
|
368
367
|
return __awaiter(this, void 0, void 0, function* () {
|
|
369
368
|
method = method.toUpperCase();
|
|
370
369
|
headers = Object.assign({}, this.headers, headers);
|
|
371
|
-
headers.Origin = `appwrite-${
|
|
370
|
+
headers.Origin = `appwrite-${reactNative.Platform.OS}://${this.config.platform}`;
|
|
372
371
|
let options = {
|
|
373
372
|
method,
|
|
374
373
|
headers,
|
|
@@ -2310,7 +2309,12 @@ class Storage extends Service {
|
|
|
2310
2309
|
position: offset,
|
|
2311
2310
|
length: Service.CHUNK_SIZE
|
|
2312
2311
|
});
|
|
2313
|
-
|
|
2312
|
+
var path = `data:${file.type};base64,${chunk}`;
|
|
2313
|
+
if (reactNative.Platform.OS.toLowerCase() == 'android') {
|
|
2314
|
+
path = FileSystem__namespace.cacheDirectory + '/tmp_chunk';
|
|
2315
|
+
yield FileSystem__namespace.writeAsStringAsync(path, chunk, { encoding: FileSystem__namespace.EncodingType.Base64 });
|
|
2316
|
+
}
|
|
2317
|
+
payload['file'] = { uri: path, name: file.name, type: file.type };
|
|
2314
2318
|
response = yield this.client.call('post', uri, apiHeaders, payload);
|
|
2315
2319
|
if (onProgress) {
|
|
2316
2320
|
onProgress({
|