Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Uploading file to google drive via drive API messes up umlauts

I am uploading a file to Google Drive with the following code snippet using the Drive API, but when I look at the contents of the file in Google Drive, the umlauts are messed up.

chrome.identity.getAuthToken({ interactive: true }, token => {
        var metadata = {
            name: 'testname.json',
            mimeType: 'application/json'
        };
        var fileContent = {
            title: "Test Title",
            notes: "Ää",
            last_changed: "1641862146889",
            url: "https://www.example.org",
            poster_url: "https://www.example.org"
        };
        var file = new Blob([JSON.stringify(fileContent)], { type: 'application/json' });
        var form = new FormData();
        form.append('metadata', new Blob([JSON.stringify(metadata)], { type: 'application/json' }));
        form.append('file', file);

        for (var pair of form.entries()) {
            console.log(pair[0], pair[1].text());
        }

        var xhr = new XMLHttpRequest();
        xhr.open('POST', 'https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart');
        xhr.setRequestHeader('Authorization', 'Bearer ' + token);
        xhr.responseType = 'json';
        xhr.onload = () => {
            var fileId = xhr.response.id;
            /* Do something with xhr.response */
            console.log(xhr.response);
        };
        xhr.send(form);
    });

Messed up umlauts(notes property):

{"title":"Test Title","notes":"Ää","last_changed":"1641862146889","url":"https://www.example.org","poster_url":"https://www.example.org"}

Does someone know how to prevent this from happening? After some troubleshooting, I also think it is possible that the problem has something to do with Blob or FormData.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!