2

I have uploaded a file on google drive, i have made it public. i am able to access this on browser but not with my android app. I need to access this public link on MY ANDROID APP. PFB the link of file: https://drive.google.com/file/d/0B56C1LC3IVXCV055WFIyVTZjTTA/edit?usp=docslist_api Is this possible to access a publicly shared GD file on android app?

Code snippet is

URL url = new URL("https://drive.google.com/file/d/0B56C1LC3IVXCV055WFIyVTZjTTA/edit?usp=docslist_api");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
return bmp;
Sirconrad
  • 69
  • 1
  • 3
  • 7

5 Answers5

1

The solution is to format the address of the document you have shared.

Check this :

URL = "https://docs.google.com/uc?id=" + IDFile + "&export=download";
Jouby
  • 2,196
  • 2
  • 21
  • 33
0

How about scaling the picture down to a reasonable size, it may just be that the image is too large for your heap to load

Bitmap.createScaledBitmap(Bitmap src, int Width, int Height, boolean filter)

Tobi Akerele
  • 962
  • 10
  • 20
  • Image size is about 120kb, This is not big size.? https://s3.amazonaws.com/prod.tracker2/resource/47529028/hey_big.jpg?AWSAccessKeyId=AKIAIKWOAN6H4H3QMJ6Q&Expires=1436170027&Signature=NI0r61zldvgJ1Mp1dKSKE6Ex2c8%3D this open link is working well. – Sirconrad Jun 29 '15 at 08:41
0

Your link is not to image but to Google Drive App with this image opened, real URL to image is this

Consider using Google Drive API

Max77
  • 1,466
  • 13
  • 19
0

There one other way to access file's public link By adding :

https://googledrive.com/host/[folderId]/fileName.extension

As you have provide file url

You can use that url like this for public access

https://googledrive.com/host/0B56C1LC3IVXCV055WFIyVTZjTTA
chiragchavda.ks
  • 532
  • 7
  • 25
  • My question is, Can i access this public URL yes or no? becuse i am able to access in browser. – Sirconrad Jun 29 '15 at 09:35
  • yo want to know if you can access it in javascript? – chiragchavda.ks Jun 29 '15 at 09:36
  • I want to know, Can i access this in android app or not? because in web browser its possible to access. – Sirconrad Jun 29 '15 at 09:38
  • https://drive.google.com/file/d/0B56C1LC3IVXCV055WFIyVTZjTTA/edit?usp=docslist_api this is the link. I am not able to open image in andorid but it is possible in web browser. – Sirconrad Jun 29 '15 at 09:40
  • you can access this file by this link :> https://googledrive.com/host/0B56C1LC3IVXCV055WFIyVTZjTTA – chiragchavda.ks Jun 29 '15 at 09:59
  • https://googledrive.com/host/0B56C1LC3IVXCV055WFIyVTZjTTA This is not woking but after click url a new URL generated . this is not working in andorid. – Sirconrad Jun 29 '15 at 10:16
  • after click above link a new click is created that is working for me in andorid. – Sirconrad Jun 29 '15 at 10:17
  • I think you should consider using Google client api. – chiragchavda.ks Jun 29 '15 at 10:26
  • I want to access all file in my andorid app which is create from web.drive but this does not allow me to access all the file has been created from web.drive. I can access only those file has been created by app. Thanks – Sirconrad Jun 29 '15 at 11:22
  • You can do pretty much everything by client api – chiragchavda.ks Jun 29 '15 at 11:23
  • https://developers.google.com/drive/v2/reference/files/get there are lots off example here – chiragchavda.ks Jun 29 '15 at 13:17
  • If i am not wrong then it allows only those file and folder to access which is created from app not web. If a folder is created having five files from web then it will not be access able using these api. – Sirconrad Jun 29 '15 at 14:02
  • It could just simply be that your link needs you to be logged in with your google account since that may be why you were able to open the link on the web and not in your app. You should consider using the Google Drive API or Google Play Services Library to log the user in before he opens the picture. Or better still, just use another image client like a file hosting site that does not require log in info. – Tobi Akerele Jun 29 '15 at 14:06
0

You simply need to grab the webContentLink of the newly created file.

From the documentation ...

webContentLink string
A link for downloading the content of the file in a browser using cookie based authentication. In cases where the content is shared publicly, the content can be downloaded without any credentials.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115