Google Drive

Google Drive

by scottrules44

View and activate on the Corona Store

This plugins integrates Google Drive™, a places to store and manage files.

Documentation

:slight_smile:

Google cloud save has been added to this plugin. The demo, docs, and plugin have been updated. To check if you are running this version please use print(drive.version) – should be 2.0 if you are using lastest version

This plugin let app users access their OWN (previously created) Google Drive account, or let app users access only to MY (app developer) account?

Thanks.

The user has to have a google account and the data is stored in a private section of Google drive.

I had a problem compiling example, because simulator didn’t find modules googleDrive, etc. Logged to “Plugins” directory, extracted zip plugin file, moved all file extracted from “/Plugins/plugin” to “/Plugins” and now example can start without problems.

That is odd

That is my fault, Let me do a quick update

This was just pushed, give it an hour and it should be working

OK:

print (drive.version) —> 2.0

Ok:

In main.lua —> local drive = require(“plugin.googleDrive”)

This validates Google user and redirects. No problem now.

Sorry, me again…

I can in fact upload a .zip file, (i.e. prueba.zip, about 10 Mbyte). The source file in device is tested OK. The uploaded file to Drive looks like a corrupted file. Should I change the MIME type in request or any other feature? Thanks.

Are you uploading to app folder or just main drive

Just main drive.

Try setting mimeType to application/zip

No success. I will keep on trying later. I think file has been base-64 encoded, and embedded into a plain (application/json???) file…

I’ll post if i am able to get it.

By the way, this is content of uploaded file:

–MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2

Content-Type: application/json; charset=UTF-8"

{“name”:“prueba”}

–MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2

Content-Type: application/json; charset=UTF-8"

{“parents”:[“appDataFolder”]}

–MPFD-c7438d84ddfd075629f3b83aaf5fee687407b7a2

content-disposition: form-data; name=“prueba”; filename=“prueba.zip”

Content-Type: application/zip

Content-Transfer-Encoding: base64

UEsDBBQAAAAIAHucHUkv2b59JR4AAIoeAAAOAAAASWNvbi02MEAzeC5wbmdVWQVUlO0SRkBEBKSk

c5HullaWFlhSumFZQEK6+UE6pGspaZYUpEFAlu5OCelwaRCQuN9/89w9O7tnz35vzTwz88y8kepq…

(here continues all base-64 encoded zip file)

I’ll take a look when I get to my computer

I just did a working test

Screen%20Shot%202016-08-31%20at%201.09.0

local fileName = "test.zip" drive.request("https://www.googleapis.com/upload/drive/v3/files/", "POST", function ( e ) print(e.response) end, {uploadType= "multipart"}, {name = fileName}, fileName, system.ResourceDirectory, "application/zip", fileName )

Windows support added for web view added in the recent daily builds.

Dear Scott,

I think this is the correct place to speak about this plugging and possible bugs.

1st. Will this plug support the new policies for Google for the next April 20th ?

(https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html)

The rollout schedule for the deprecation of web-views for OAuth requests to Google is as follows. Starting  October 20, 2016 , we will prevent new OAuth clients from using web-views on platforms with a viable alternative, and will phase in user-facing notices for existing OAuth clients. On  April 20, 2017,  we will start blocking OAuth requests using web-views for all OAuth clients on platforms where viable alternatives exist.

  1. All names for the files uploaded to the application folder lost his own name, and change to ‘Untitled’. This make impossible to get the correct ID for the file we need to download.

 

EXAMPLE:

 

drive.request(“https://www.googleapis.com/drive/v3/files/”, “GET”, function ( e ) 

print(e.response)

end, {spaces= “appDataFolder”} )

 

 

GIVES THIS ANSWER (I have uploaded 2 files)

 

 

{

 “kind”: “drive#fileList”,

 “files”: [

  {

   “kind”: “drive#file”,

   “id”: “1gi4QMQ12wZkI1wMcBic1OgM8cHLpZhqk37-2ZLhVn-KO”,

   “name”: “Untitled”,

   “mimeType”: “application/octet-stream”

  },

  {

   “kind”: “drive#file”,

   “id”: “11uoK3859IMBFeYtRp4SgixXrOe7klttXXudpbwfX0_6X”,

   “name”: “Untitled”,

   “mimeType”: “application/octet-stream”

  }

 ]

}

 

 

Note that the name is ‘Untitled’ for both files. Not possible to identify the correct file to download.

 

I think this is a bug dear.

 

 

  1. Is there any way to create folders to upload files to?

Google explain that need to change the mimeType to

mimeType = “application/vnd.google-apps.folder”

 

But I have been testing and the mime type always is the same. Any way to create folders by this way or other?

 

 

 

Thanks again for your great job.

 

 

A lot of stuff there

let me try to break it down

  1. I not received anything on mac simulator, I am looking into this. I think iOS is the major problem. I will try to implement slowly as time goes along. 

as for the other stuff I just want to address that way plugin is, it is designed to allow access to the drive rest api. So this “bug” is not with plugin self, it is the way it’s used. It like making the comparison that the network api are broken because I am getting server errors. It could be networking apis, but it is mostly likely the way its being used or the server.

 I have been trying myself and I cannot get it working. I honestly know just as much as you do about every google drive api. I feel this google bug based on the way google drive documentation is written.