RobinBobin / react-native-google-drive-api-wrapper

This wrapper facilitates the use of the Google Drive API in React Native projects.
110 stars 43 forks source link

Upload SQLite3 db file #92

Closed MateoGonzalez22 closed 1 year ago

MateoGonzalez22 commented 1 year ago

Hi, im trying to upload a sqlite3 db file as a backup to drive, i tried the example code in the README that uses newMultipartUploader().

I tried this:

 const databaseFile = await RNFS.readFile(databaseFilePath, 'base64')

const res = (await gdrive.files.newMultipartUploader()
    .setData(databaseFile, MimeTypes.BINARY)
    .setRequestBody({
        name: "database.db"
    })
    .execute()
);

Reading the db as base64 seems to work right since i tried writing a new db file based on the base64 content and it works fine.

When the database.db is uploaded its in text/plain mimeType and its unreadable for sqlite editors

I also tried const newDbContent = await gdrive.files.getBinary(id) but writing a file with that content doesnt work

I really dont understand how file encoding types work so i dont know if im missing something.

MateoGonzalez22 commented 1 year ago

I forget to use .setIsBase64(true), that solved the issue

RobinBobin commented 1 year ago

Congrats 🎉 !