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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-native-appwrite",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "0.2.0",
5
+ "version": "0.2.2",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "dist/cjs/sdk.js",
8
8
  "exports": {
@@ -34,9 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "expo-file-system": "16.0.8",
37
- "expo-device": "5.9.3"
37
+ "react-native": "^0.73.6"
38
38
  },
39
39
  "peerDependencies": {
40
- "expo": "*"
40
+ "expo": "*",
41
+ "react-native": "*"
41
42
  }
42
43
  }
package/src/client.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Models } from './models';
2
2
  import { Service } from './service';
3
- import * as Device from 'expo-device';
3
+ import { Platform } from 'react-native';
4
4
 
5
5
  type Payload = {
6
6
  [key: string]: any;
@@ -249,7 +249,7 @@ class Client {
249
249
  // @ts-ignore
250
250
  this.realtime.socket = new WebSocket(url, undefined, {
251
251
  headers: {
252
- Origin: `appwrite-${Device.osName}://${this.config.platform}`
252
+ Origin: `appwrite-${Platform.OS}://${this.config.platform}`
253
253
  }
254
254
  });
255
255
  this.realtime.socket.addEventListener('message', this.realtime.onMessage);
@@ -367,7 +367,7 @@ class Client {
367
367
  method = method.toUpperCase();
368
368
 
369
369
  headers = Object.assign({}, this.headers, headers);
370
- headers.Origin = `appwrite-${Device.osName}://${this.config.platform}`;
370
+ headers.Origin = `appwrite-${Platform.OS}://${this.config.platform}`;
371
371
  let options: RequestInit = {
372
372
  method,
373
373
  headers,
@@ -3,6 +3,7 @@ import { AppwriteException, Client } from '../client';
3
3
  import type { Models } from '../models';
4
4
  import type { UploadProgress, Payload } from '../client';
5
5
  import * as FileSystem from 'expo-file-system';
6
+ import { Platform } from 'react-native';
6
7
 
7
8
  export class Storage extends Service {
8
9
 
@@ -139,8 +140,12 @@ export class Storage extends Service {
139
140
  position: offset,
140
141
  length: Service.CHUNK_SIZE
141
142
  });
142
-
143
- payload['file'] = {uri: `data:${file.type};base64,${chunk}`, name: file.name, type: file.type};
143
+ var path = `data:${file.type};base64,${chunk}`;
144
+ if (Platform.OS.toLowerCase() == 'android') {
145
+ path = FileSystem.cacheDirectory + '/tmp_chunk';
146
+ await FileSystem.writeAsStringAsync(path, chunk, {encoding: FileSystem.EncodingType.Base64});
147
+ }
148
+ payload['file'] = {uri: path, name: file.name, type: file.type};
144
149
  response = await this.client.call('post', uri, apiHeaders, payload);
145
150
 
146
151
  if (onProgress) {