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/esm/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as Device from 'expo-device';
1
+ import { Platform } from 'react-native';
2
2
  import * as FileSystem from 'expo-file-system';
3
3
 
4
4
  /******************************************************************************
@@ -156,7 +156,7 @@ class Client {
156
156
  // @ts-ignore
157
157
  this.realtime.socket = new WebSocket(url, undefined, {
158
158
  headers: {
159
- Origin: `appwrite-${Device.osName}://${this.config.platform}`
159
+ Origin: `appwrite-${Platform.OS}://${this.config.platform}`
160
160
  }
161
161
  });
162
162
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
@@ -345,7 +345,7 @@ class Client {
345
345
  return __awaiter(this, void 0, void 0, function* () {
346
346
  method = method.toUpperCase();
347
347
  headers = Object.assign({}, this.headers, headers);
348
- headers.Origin = `appwrite-${Device.osName}://${this.config.platform}`;
348
+ headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}`;
349
349
  let options = {
350
350
  method,
351
351
  headers,
@@ -2287,7 +2287,12 @@ class Storage extends Service {
2287
2287
  position: offset,
2288
2288
  length: Service.CHUNK_SIZE
2289
2289
  });
2290
- payload['file'] = { uri: `data:${file.type};base64,${chunk}`, name: file.name, type: file.type };
2290
+ var path = `data:${file.type};base64,${chunk}`;
2291
+ if (Platform.OS.toLowerCase() == 'android') {
2292
+ path = FileSystem.cacheDirectory + '/tmp_chunk';
2293
+ yield FileSystem.writeAsStringAsync(path, chunk, { encoding: FileSystem.EncodingType.Base64 });
2294
+ }
2295
+ payload['file'] = { uri: path, name: file.name, type: file.type };
2291
2296
  response = yield this.client.call('post', uri, apiHeaders, payload);
2292
2297
  if (onProgress) {
2293
2298
  onProgress({