Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gibberish returned from gapi.client.drive.files.get() using alt: 'media' if content includes non-English (charset?) letters #1188

Open
thexs-dev opened this issue Jan 21, 2024 · 1 comment

Comments

@thexs-dev
Copy link

I am using the following code to get the content of a text file uploaded (plain text with MimeType.JAVASCRIPT) to Google Drive.

let response = await gapi.client.drive.files.get({
  'fileId': "google-drive-file-id-goes-here", alt: 'media'
});
let content = response.body;

It gets the actual content in Google Drive if the content only includes English (charset?) letters

  • But if the file has other letters, the content shows them as gibberish instead

See example below for the word Pharmacy in other languages and what the content is showing between ()

  • Hebrew: בית מרקחת (× × ×ª × ×¨×§× ×ª)
  • Japanese 薬局 (è ¬å±)
  • Arabic: مقابل (٠٠ابÙ)

How to fix this issue using the gapi.client.drive.files.get() function?

Thanks in advance for your support on this
Fausto

@adevine
Copy link

adevine commented May 5, 2024

There is what I would consider a bug in the /drive/v3/files/${fileID} endpoint that's hit when calling drive.files.get or drive.files.export in that the server is always returning a Content-Type of "text/plain;charset=UTF-8". This Stack Overflow answer, https://stackoverflow.com/a/63818644/1075909, explains how to work around this. Other related SO post, https://stackoverflow.com/questions/66799006/unwanted-content-type-text-plaincharset-utf-8-header-in-google-drive-api-res

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@adevine @thexs-dev and others