I'm trying to implement App Engine app that should upload files from user computer to Team Drive folder.
Currently I'm trying to do it with .jsp and servlets but it seems that it couldn't be done that way.
I'm using Service Account and Drive API Client Library for Java - https://developers.google.com/api-client-library/java/apis/drive/v3
It seems that when uploading files in such way you should use java.io.File which is impossible on App Engine, because file isn't stored on instance but it is uploaded from user computer.
Is it any way to upload file directly to Google Drive using App Engine?
Additional note:
I'm using Drive API v3.
In Drive API v2 there was file.insert() method available which lets you sending InputStream as input parameter. I think such method could help me with upload but it is not included in API v3.
https://developers.google.com/drive/api/v2/reference/files/insert
I think you're looking for protected Create(File content, com.google.api.client.http.AbstractInputStreamContent mediaContent) from https://developers.google.com/resources/api-libraries/documentation/drive/v3/java/latest/
Related
We have audio files which should be streamed to authenticated users. All the audios are encrypted.
Our current approach is to decrypt file download in a public web directory on the server which has the file name in a predefined format. If called using link this file is playable on any client i.e. web or mobile. But we have security challenges as this file is in public directory anyone with basic browser knowledge can get a link and play it without authentication.
Is there any secure way to stream an audio file using authentication? Any standard practice in Java REST frameworks, spring-boot, dropwizard etc?
All,
I have a google application engine (java) that requires to store some images. I tried using Blobs and storing them in datastore but as you know there is a size limit on data that can be stored in datastore.
So as result I'm storing the images on a different server and store the path in my datastore and all works fine.
Now I'm thinking on using a google drive folder instead of using a server to upload the files to the drive and using the share link to display them later.
I've seen https://developers.google.com/drive/web/quickstart/java and got it to work fine. When I try to use it in my application however obviously this won't work as the code is assuming a credential for a local user.
I created a service key on my application and want to change the sample code above to use it but I'm not sure if that's the correct approach.
Tried searching for samples but can't find anyone that takes the same approach. Is there a working sample that shows how to authenticate an application not a user and let's say store a file in google drive?
I've also seen https://developers.google.com/drive/web/examples/ please note what I want is to store files in my google drive and not the user's google drive. So if user A and user B come to my app, they shouldn't have to authorize my application and should both be able to upload a file to my google drive.
I don't know if this can be done directly from their browser or I have to move the file to my application (appspot) and then push it to google drive.
Thanks
Since 2 days Googling, I got to upload a file in Google Cloud Storage using java. Now I am facing troubles to download the same file from Google Cloud Storage using java.
I tried with BlobstoreService to upload a file. Can any body give me the suggestions to download from the GCS?
If you want to read a file on Google Cloud Storage from an App Engine application, you need to use the Google Cloud Storage Java Client Library, or you can read it using Blobstore API after you get the blobstore key using the function createGsBlobKey.
Using Google Cloud Storage Java Client Library in order to read/write files is fairly simple. Check out this page for more info:
https://developers.google.com/appengine/docs/java/googlecloudstorageclient/getstarted
I have an android application, which wants the user to login each time he runs the app. So, the login procedure is simple, using the sqlite dabase file i'm using. I've copied the file in assets folder and doing the necessary modifications. But, the database file is of no use unless it is on the server. I don't have any server so i'm thinkin of keeping the database file on dropbox, google drive etc and then read or update that file as per user commands. The question is how to do that? I was searching the web for it, and found that the only way is downloading the db file modifying it and the uploading it back. Can anyone give me an example??
Doing that isn't possible unless you have a server.
Because, if you are using dropbox, first you'll have to make your file public in order to download it (Not recommended at all. Compromises security). Then you can use the url to download the file. But you won't be able to upload it back (Unless you are able to login to dropbox through your Android code).
Instead if you a web server with MySQL n PHP, you can easily send POST requests to your server.
I'm trying to make use of the Google Drive APIs to send a log file created by our application to our company's Google Drive Account that we share for Android Development. Most of the examples showed how to use oAuth2 to authenticate with the end-user's Google Drive Account, but we want the files to be sent to just our Google Drive Account.
After some searching I found that I should create an API project for our app and use a Service account associated with that API Project to generate a key which we include in our project as a raw resource to authenticate using oAuth2 to get a GoogleCredential which is needed to build the Drive service we will use to make our API calls.
After authenticating properly, I was able to insert a file using the code example on the Google Drive API site and that appears to work properly, however I cannot see the file in our Google Drive account which created the API Project/Service account. Despite this, if I call Drive.files().list().execute() and output the FileList to a string I was able to see the files our app has previously inserted into the Service account's Google Drive.
So my question is: Is there a new Google Drive account created for the Service account that is separate from the Google Drive account that created the Service account? If so, is there a way to login to that account and view the files using the normal Google Drive Web UI so that we can get to the log files without writing some other application that authenticates with the Service account and then grabs the files?
It appears my question ended up being a duplicate, the other question one was just a little bit hard to find for me. The question is I can't see the files and folders created via code in my Google Drive and it was answered by a Google employee: https://stackoverflow.com/a/12218662/994519