Skip to content

Commit

Permalink
Merge pull request #8 from appwrite/fix-android-upload
Browse files Browse the repository at this point in the history
fix android chunk upload
  • Loading branch information
lohanidamodar authored Mar 27, 2024
2 parents 2a40942 + d5dd847 commit 52a2645
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-appwrite",
"homepage": "https://appwrite.io/support",
"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",
"version": "0.2.0",
"version": "0.2.1",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
Expand Down
9 changes: 7 additions & 2 deletions src/services/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AppwriteException, Client } from '../client';
import type { Models } from '../models';
import type { UploadProgress, Payload } from '../client';
import * as FileSystem from 'expo-file-system';
import * as Device from 'expo-device'

export class Storage extends Service {

Expand Down Expand Up @@ -139,8 +140,12 @@ export class Storage extends Service {
position: offset,
length: Service.CHUNK_SIZE
});

payload['file'] = {uri: `data:${file.type};base64,${chunk}`, name: file.name, type: file.type};
var path = `data:${file.type};base64,${chunk}`;
if (Device.osName == 'Android') {
path = FileSystem.cacheDirectory + '/tmp_chunk';
await FileSystem.writeAsStringAsync(path, chunk, {encoding: FileSystem.EncodingType.Base64});
}
payload['file'] = {uri: path, name: file.name, type: file.type};
response = await this.client.call('post', uri, apiHeaders, payload);

if (onProgress) {
Expand Down

0 comments on commit 52a2645

Please sign in to comment.