i just did a test, downloading the data still works
Dear Scott,
Thanks again for answer.
Dear, the problem is:
If I don’t know the correct ID, then I can’t download the file.
Due all the files uploaded to the application folder, lost his own name, and all are named ‘Untitled’, then I can’t find the correct ID because I don’t know which one file is the correct to download.
The problem is that, when upload files to application folder, the name lost, and all the files are named Untitled.
Has you seen this in your test?
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.
I will look into it
Dear Scott,
Sorry my delay in answer.
I’m testing with the drive.createFileInAppData , and drive.listFilesInAppData but always the corona simulator give me the error:
Attempt to call field ‘createFileInAppData’ (a nil value)
and
Attempt to call field ‘listFilesInAppData’ (a nil value)
I’m using your example code. But appear not work for the application folder.
I’m missing any?
Thanks again in advance,
Is
drive.onlyAppAccess(true)
Called before login?
Dear Scott,
Thanks again for your quick answer and sorry for my delay.
Dear, yes. The problem is that
drive.onlyAppAccess(true)
give an error.
Corona say: 'Attempt to call field ‘onlyAppAccess’ (a nil value)
The same error I have for others:
drive.createFileInAppData
To include the plugging I do:
local drive = require(“plugin.googleDrive”) – (not this due this don’t work --> “drive.googleDrive”)
I’m testing your example. The normal works fine and perfect, but all for the AppData fails. Appear to not recognize createFileInAppData.
Perhaps configuration?
Thanks again for your excellent work.
This code works for me
local drive = require("plugin.googleDrive") local json = require("json") local canMakeRequest = false drive.onlyAppAccess(true) drive.init("insert your stuff here") -- update this local signOutButton local requestButton local loginButton = display.newGroup() loginButton.box = display.newRoundedRect( loginButton,0, 0, 100, 50, 10 ) loginButton.myText = display.newText( loginButton, "Login", 0, 0 , native.systemFont , 15 ) loginButton.myText:setFillColor( 0 ) loginButton.x, loginButton.y = display.contentCenterX, display.contentCenterY loginButton.alpha = 1 loginButton.box:addEventListener( "tap", function ( event ) local function driveLis( e ) print(e.error) if (not e.error) then canMakeRequest = true signOutButton.alpha = 1 requestButton.alpha = 1 loginButton.alpha = 0 end end drive.login(driveLis) end) requestButton = display.newGroup() requestButton.box = display.newRoundedRect( requestButton,0, 0, 100, 50, 10 ) requestButton.myText = display.newText( requestButton, "Request", 0, 0 , native.systemFont , 15 ) requestButton.myText:setFillColor( 0 ) requestButton.x, requestButton.y = display.contentCenterX, display.contentCenterY-100 requestButton.alpha = 0 requestButton.box:addEventListener( "tap", function ( e ) --upload image --[[local fileName = "arrow" drive.request("https://www.googleapis.com/upload/drive/v3/files/", "POST", function ( e ) print(e.response) end, {uploadType= "multipart"}, {name = fileName, parents ={"appDataFolder"}}, fileName..".png", system.ResourceDirectory, "image/png", fileName ) --]] --delete file --[[local fileId = "0B5swSg-cH4L6cjdTWU94RTNDR0E" drive.request("https://www.googleapis.com/upload/drive/v3/files/"..fileId, "DELETE", function ( e ) print(e.response) end, {fileId= fileId} )]]-- --update file --[[local fileId = "0B5swSg-cH4L6cjdTWU94RTNDR0E" local fileName = "arrow" drive.request("https://www.googleapis.com/upload/drive/v3/files/"..fileId, "PATCH", function ( e ) print(e.response) end, {fileId= fileId, uploadType= "multipart"}, {name = fileName}, fileName..".png", system.ResourceDirectory, "image/png", fileName )]]-- --list file(s) --[[drive.request("https://www.googleapis.com/drive/v3/files/", "GET", function ( e ) print(e.response) end, {orderBy ="modifiedTime"} )]]-- --download file --[[local fileId = "" drive.download(fileId, nil, function ( e ) print(e.response) end ,"arrow.png", system.TemporaryDirectory) --]] ------------- ----app folder requests --upload to app folder ----[[local fileName = "config.json" print(fileName) drive.request("https://www.googleapis.com/upload/drive/v3/files/", "POST", function ( e ) print(e.response) end, {uploadType= "multipart"}, {name = fileName, mimeType = "application/json", parents={"appDataFolder"}},"config.json", system.ResourceDirectory, "application/json", fileName ) --]] --list files --[[drive.request("https://www.googleapis.com/drive/v3/files/", "GET", function ( e ) print(e.response) end, {spaces= "appDataFolder"} )]]-- --download file --[[local fileId = "1a26sFl6YLCj0hbHX\_3CpspysgrF71VpTp5QAn27VGro" drive.download(fileId, nil,function ( e ) print(json.encode(e.response)) end ,"config.json", system.TemporaryDirectory)]]-- end ) signOutButton = display.newGroup() signOutButton.box = display.newRoundedRect( signOutButton,0, 0, 100, 50, 10 ) signOutButton.myText = display.newText( signOutButton, "Sign Out", 0, 0 , native.systemFont , 15 ) signOutButton.myText:setFillColor( 0 ) signOutButton.x, signOutButton.y = display.contentCenterX, display.contentCenterY+100 signOutButton.alpha = 0 signOutButton.box:addEventListener( "tap", function ( e ) drive.signOut(function ( event ) if not event.error then signOutButton.alpha = 0 requestButton.alpha = 0 loginButton.alpha = 1 canMakeRequest = false end end) end )
Ps updated sample to fix that issue with the require
Dear Scott,
I have been testing and work perfect now. The AppFolder is hidden to the user in google drive and secure. And works fine.
Only 1 question: I’m trying to create a folder to upload the files to this new folder. Google explain that need to change the mimeType to
mimeType = “application/vnd.google-apps.folder”
Any way to do it?
If I try the following:
local fileName = “arrow”
drive.request(“https://www.googleapis.com/upload/drive/v3/files/”, “POST”, function ( e )
print(e.response)
end, {uploadType= “multipart”}, {name = fileName, mimeType = “application/vnd.google-apps.folder”}, fileName …".png", system.ResourceDirectory, “image/png”, fileName )
The answer is:
nil
{
“kind”: “drive#file”,
“id”: “0B-0lZ-JxWcf1bWRQRzFsSWxSZ2s”,
“name”: “arrow”,
“mimeType”: “application/octet-stream”
}
Any way to change the mimeType?
or
Any way to create a folder and to upload files to that folder?
Dear, thanks again for your excellent job,
Dear, also the name for the file when using the app data folder always go Untitled…
Using this:
local fileName = “config.json”
print(fileName)
drive.request(“https://www.googleapis.com/upload/drive/v3/files/”, “POST”, function ( e )
print(e.response)
end, {uploadType= “multipart”}, {name = fileName, mimeType = “application/json”, parents={“appDataFolder”}},“config.json”, system.ResourceDirectory, “application/json”, fileName )
Cause this result:
{
“kind”: “drive#file”,
“id”: “1gi4QMQ12wZkI1wMcBic1OgM8cHLpZhqk37-2ZLhVn-KO”,
“name”: “Untitled”,
“mimeType”: “application/octet-stream”
}
And when list the files with:
drive.request(“https://www.googleapis.com/drive/v3/files/”, “GET”, function ( e )
print(e.response)
end, {spaces= “appDataFolder”} )
Answer all my files in appdatafolder that all named in the same way Untitled
{
“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”
}
]
}
Using the user space (not appdatafolder) works well and keep the correct name, but not the mime type.
Using the app data folder lost the name and all names go to ‘Untitled’. Also I think lost the mime type due always is “application/octet-strem”
Let me know if I can help you in any way with testings.
Thanks again dear,
i just did a test, downloading the data still works
Dear Scott,
Thanks again for answer.
Dear, the problem is:
If I don’t know the correct ID, then I can’t download the file.
Due all the files uploaded to the application folder, lost his own name, and all are named ‘Untitled’, then I can’t find the correct ID because I don’t know which one file is the correct to download.
The problem is that, when upload files to application folder, the name lost, and all the files are named Untitled.
Has you seen this in your test?
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.
I will look into it