Skip to content

Commit bbbb5ce

Browse files
committed
use expo file system
1 parent 132ca5e commit bbbb5ce

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

templates/react-native/src/services/template.ts.twig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Service } from '../service';
22
import { {{ spec.title | caseUcfirst}}Exception, Client } from '../client';
33
import type { Models } from '../models';
44
import type { UploadProgress, Payload } from '../client';
5-
import fs from 'react-native-fs'
5+
import * as FileSystem from 'expo-file-system';
66

77
{% set added = [] %}
88
{% for method in service.methods %}
@@ -139,7 +139,11 @@ export class {{ service.name | caseUcfirst }} extends Service {
139139
apiHeaders['x-{{spec.title | caseLower }}-id'] = response.$id;
140140
}
141141

142-
let chunk = await fs.read({{ parameter.name | caseCamel | escapeKeyword }}.uri, Service.CHUNK_SIZE, offset, 'base64');
142+
let chunk = await FileSystem.readAsStringAsync(file.uri, {
143+
encoding: FileSystem.EncodingType.Base64,
144+
position: offset,
145+
length: Service.CHUNK_SIZE
146+
});
143147

144148
payload['{{ parameter.name }}'] = {{ '{' }} uri: `data:${{'{'}}{{ parameter.name | caseCamel | escapeKeyword }}.type{{'}'}};base64,${{'{'}}chunk{{'}'}}`, name: {{ parameter.name | caseCamel | escapeKeyword }}.name, type: {{ parameter.name | caseCamel | escapeKeyword }}.type {{ '}' }};
145149

0 commit comments

Comments
 (0)