Search code examples
androidcsvgoogle-drive-apiexport-to-csvgoogle-drive-android-api

Android - Google Drive REST API - Adding a row to a CSV file


This question concerns adding a new row to a CSV file that exists in Google Drive using the Google Drive REST API.

On my Android device, I have a CSV file that I am building locally. If I add a row to the local CSV, I want to also add that row to the CSV that resides on Google Drive.

I've got the fileId of the CSV, and I can PUT the file to do a direct replacement, but I'm trying to save bandwidth as the file size grows.

I have been looking into JSON Patch as the transport to perform this, but I cannot find a concrete example after looking for days. For instance, how does JSON Patch write to the CSV file? Is the "path:" parameter the column header? Is a "op", "add" needed for each column?

I just need to pointed in the right direction.


Solution

  • To my best knowledge, it is not possible. You are trying to append (modify) the content of a file and the only way I know of in both the REST Api and the GDAA is to get the content, modify it and upload. It is possible that GDAA may (one day) internally do some diff / incremental optimization, but I doubt it.

    My rational for this guess is that the content is being shipped as base64-ed, gzip-ed, ... binary stream with no embedded knowledge of the mime type, so the 'append' functionality would get quite complex.

    The PATCH functionality you'r looking into deals only with METADATA (title, mime, modi-dates, parentIDs, etc...). See the fields available in Try it! on the bottom of this page.

    Good Luck