Skip to content

Commit 4fd7e77

Browse files
committed
fix: fixed encoding of text from base64 to utf-8 to fix it from eating special characters and spaces
1 parent bc271e8 commit 4fd7e77

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

expo-example/app/document/blob/setBlob.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export default function DocumentSetBlobScreen() {
2222
documentId: string
2323
): Promise<string[]> {
2424
try {
25-
const encoder = new TextEncoder();
26-
const blob = new Blob('text/plain', encoder.encode(blobText));
27-
const mutDoc = await setBlob(collection, documentId, key, blob);
25+
const mutDoc = await setBlob(collection, documentId, key, blobText);
2826
if (
2927
mutDoc !== undefined &&
3028
mutDoc !== null &&

expo-example/service/document/getBlob.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export default async function getBlob(
1010
const doc = await collection.document(documentId);
1111
const blobText = await doc.getBlobContent(key, collection);
1212
if (blobText !== undefined && blobText !== null) {
13-
const text = Buffer.from(blobText).toString('utf-8');
13+
const buffer = Buffer.from(blobText);
14+
const text = buffer.toString('utf-8');
1415
return text;
1516
}
1617
} catch (error) {

expo-example/service/document/setBlob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default async function setBlob(
77
key: string,
88
blobText: string
99
): Promise<Document> {
10-
const bufferText = Buffer.from(blobText, 'base64');
10+
const bufferText = Buffer.from(blobText, 'utf-8');
1111
const blob = new Blob('text/plain', bufferText);
1212
const doc = await collection.document(documentId);
1313
const mutableDoc = MutableDocument.fromDocument(doc);

0 commit comments

Comments
 (0)