DKV
DKV

Reputation: 1767

Is it possible to get the link of uploaded file from google drive API

I was going through the Google drive API lists Drive. Is that possible to get the link of the files that uploaded in the drive programmatically from my app? Like a Picked.

I found API for upload and download. I also found google drive search parms. But didn't find anything like browse to the files and get the link of the same.

Is that possible?. I don't need to Upload anything, just the link of an already uploaded file. There is some good documentation on the web, but finding it and making sense of it can be a challenge, especially since the names of the packages are so similar.

Upvotes: 3

Views: 1886

Answers (3)

pinoyyid
pinoyyid

Reputation: 22306

I don't really understand your use case, but to answer the question "how do I get a list of files created by my app"...

  1. Create an Access Token using a scope of drive.files
  2. Write an app that uses files.list to query all files (ie. q='trashed=false')
  3. Run your app using that Access Token. The result will be a list of files created by your app.

Upvotes: 0

DKV
DKV

Reputation: 1767

You can list all the file from the drive using API. But you can access files that are created from your app only.

The Android Drive API only works with the googleapis.com/auth/drive.file scope. This means that only files which a user has opened or created with your application can be matched by a query.

Please find the below image. You are not able to get any of the details. Check the GitHub enter image description here

Upvotes: 0

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117016

The google drive is just a file store, and google drive api just lets you access that file store. Unless your application tracks which files it has uploaded there is really no way for you to know which files where uploaded by your application as opposed to another application.

Unless your application is only storing files in the app data folder you can get a list of the files your application has stored in the app data folder and be sure that they where only files uploaded by your application.

You could add a custom properties to the files that you upload properties this way when you run though the list of files on the user drive you could detect the ones that are yours. I am not sure if file.list search will work on properties i cant remember if it does or not.

I may have missunderstood I thought you only wanted the files your application had uploaded. Depending upon the type of the file if you check file response you will see that there are sevral links webContentLink and webContentView link may be of use to you. Just remember not all files have this binary files probably wont for example.

Upvotes: 2

Related Questions