2

I can use javascript Google API to authentifie my webapp and create new file in Google Drive, as it's explained in this post :

function createNewFile() {
    gapi.client.load('drive', 'v2', function() {
        var request = gapi.client.request({
            'path': '/drive/v2/files',
            'method': 'POST',
            'body':{
                "title" : "test.txt",
                "description" : "Some"
            }
        });
        request.execute(function(resp) { console.log(resp); });
    });
}

It creates an empty file in Drive. But I don't know how to create a new non-empty file by adding text content to it (for example "blablabla"). Can someone please help me ?

Community
  • 1
  • 1
  • Have a loot at this [answer](http://stackoverflow.com/questions/10330992/authorization-of-google-drive-using-javascript/10331393#10331393). – Alain Aug 14 '12 at 18:01

1 Answers1

2

Checkout the update function I made for updating a file after insert How do I add/create/insert files to Google Drive through the API?

Read the the main answer on the page, this also hints to create/insert in one call to the API.

Community
  • 1
  • 1
user1158023
  • 337
  • 2
  • 6