Use google drive to store / retrieve files using java web app - java

We want to develop a restlet based java web app that stores and retrieves files from Google Drive. Right now, the data files are stored on the local disk and when the user clicks on a link, the file is rendered from the local disk on the server. We want to move the files to the google drive that will automatically take care of cloud storage and disk size restrictions. What we want is that when the end user clicks on a link, the file is downloaded and / or opened directly in it's browser transparently i.e. w/o any additional authentication step or input from user. Our app should take care of authentication in the background. Does Google Drive API support that as of today ? Any relevant documentation / article / sample app ?
Thanks,
Deep

You can achieve this if the user is logged into their Google account using the webContentLink of a file resource.
There is an example on the Google Drive SDK website.

Related

How to Store application-specific data of the android kotlin app in user's google drive?

I want to use the user's google drive as a database to store the app-specific data in his drive. To use it as a backup drive.
Now there is this documentation which is suppose to help how to implement it as the google says we can achieve this using google drive apis.
But there is not a single article that can help me to integrate it completely from a to z.
Some post i found but they are not again specific to the this use case i.e. "Store application-specific data". Also they are outdated
Can someone provide an up-to-date Android guide for Google Drive REST API v3?
Integrate Google Drive REST API on Android App
Im not exactly sure I understand what your issue is, so let me try to explain the documentation page for Store application-specific data that appears to be unclear to you.
Uploading to the app data folder is done exactly the same as uploading to any other folder. With three differences.
First off when you authorize your user you will need to use the scope of DriveScopes.DRIVE_APPDATA, This scope gives you access See, create, and delete its own configuration data in your Google Drive. Which will mean that you can only edit data that your application created.
Second. When you upload the file. The file type must be .json. Configuration files are .json thats it.
Finally when you upload the file you set the parent directory to appDataFolder.
var fileMetadata = new Google.Apis.Drive.v3.Data.File()
{
Name = "config.json",
Parents = new List<string>()
{
"appDataFolder"
}
};
That's it, that is the only difference with google drive api and uploading to appDataFolder. Any google drive api upload example can be used.

Protect tab/range in Google Sheet via Drive API for Java

I have an application that creates Google spreadsheets through Java code. I have looked through the permissions section in Google Drive API and I'm going to give edit access to anyone with the link.
In certain sheets I need to make only one tab 'view only', i.e. protect that tab. Is it possible to do this via Drive API?
Is it possible to give a name to the current version of the file via Drive API?

Android Google Drive SDK: Saving to App Folder

For my current project, I would like to allow a user to create a sqlite database file and have them enter some content. Then the user has the option to sign into their google drive account and upload this file. Afterwards, after the user makes further edits, the new database file is uploaded to replace the old file. Finally, if the user has multiple devices, the database should be downloaded from the google drive and replace the existing file stored on the device.
Currently, I have successfully setup Google Drive SDK authentication and I can sign in to the app with my account.
My main question is, how do I upload a sqlite database file to the APP FOLDER when I choose to press a sync button? (This method should be called when the user needs to sync)
Additionally, how do I upload a sqlite database file to the APP FOLDER?
Your question is a bit broad, but I'll try to send you in the right direction.
First you have to decide if to use the REST Api or GDAA. Both will accomplish the same (actually the GDAA's functionality is a bit narrower now, but for your situation will do).
The big difference is that GDAA will handle on-line / off-line states for you, where with the REST Api, you have to implement some kind of non-UI thread (sync service) synchronization. Also, there are latency issues you must be aware when using GDAA.
Next, the process of uploading SQLite database is the same as any other binary data stream.
Grab the 'xxx.db' file, make output stream (or byte[] buffer) and create a GooDrive file with title + mimetype metadata, push the stream into it's content and send it on it's merry way. The only difference between a standard folder and an app folder is the parent of the file.
You get an ID you can subsequently use to download the file to the device. Or you can use search by metadata (title in your case) to get this ID. Again it comes as input stream and you dump it to an 'xxx.db' file on your device.
The second portion of your question deals with multiple devices. None of the apis will notify you about a change in GooDrive, so you must implement one of the 2 strategies:
1/ Polling (ouch), preferably in sync service with sync intervals the system gives you.
2/ GCM message broadcasted to the devices / users who are interested (not trivial, but efficient ... and sexy).
Another pitfall you must be aware when using multiple devices with GDAA is described in SO 29030110 and SO 22874657.
In case you decide to play with the 2 apis, I maintain basic CRUD implementation demos for both the REST and GDAA. The GDAADemo has also an option to work with the app folder.
Good Luck

It is possible to export the local_db bin to Google app engine?

I'm new in app engine.
I created an Java application using Google app engine. I populated a database offline. I can access it at my localhost. I know that the local dev server stores data in local_db.bin.
When I upload the app to the online dev server, it doesn't upload my database. It is possible to upload the local_db.bin?
Thank you for you help.
Copying/deploying the local_db.bin file directly to Google servers will have no effect and that file is intended only for the SDK that runs locally. On production the datastore is a service and all implementation and files are hidden away from the user. Thus you can't copy or change the format for the file to achieve what you want.
See this link for
datastore copy
Depending how much data you have and how often you need to populate it then it might just be easier to re-populate it online, create some basic data bootstrapping code/script or an API/import process.

Saving Large file using GWT + GAE + S3 path

I'm building app that will store large video files to the server and then user will be able to view them. For my app I'm using GWT + GAE/J and to store files I would like to use S3 account. But as we know that you can upload max 10mb to GAE. I have asked this kind of question before and the answer that I have accepted will work only if you have file less then 10mb. That solution that KevMo have suggested uploads whole files to the server but what if my file is 20mb or 100mb. Is it possible to divide that file into 10mb peaces, send them to GAE and then assemble those files on S3 server.
Here is the picture of what I'm trying to accomplish here:
Thanks
Why not have your GWT client upload the video directly to S3? You can have your app engine code create the authentication token or password or whatever S3 calls it, and then your GWT client would send the file straight there. If need be, it could pass back whatever meta data that your app engine code needs.(file size, name, whatever)
see this question for more info on giving users permission to upload to S3:
PS - obviously this doesn't work quite as well if you are doing some kind of processing to the video in your app engine code before uploading it to S3alt text http://www.freeimagehosting.net/uploads/b49fdee149.jpg
I'd highly recommend developing your own transfer control instead. Likely it will take the same amount of time.

Categories

Resources