Skip to content

Commit 52a2645

Browse files
Merge pull request #8 from appwrite/fix-android-upload
fix android chunk upload
2 parents 2a40942 + d5dd847 commit 52a2645

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-native-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"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.1",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/services/storage.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AppwriteException, Client } from '../client';
33
import type { Models } from '../models';
44
import type { UploadProgress, Payload } from '../client';
55
import * as FileSystem from 'expo-file-system';
6+
import * as Device from 'expo-device'
67

78
export class Storage extends Service {
89

@@ -139,8 +140,12 @@ export class Storage extends Service {
139140
position: offset,
140141
length: Service.CHUNK_SIZE
141142
});
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 (Device.osName == '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};
144149
response = await this.client.call('post', uri, apiHeaders, payload);
145150

146151
if (onProgress) {

0 commit comments

Comments
 (0)