Ga Ne Sh
Ga Ne Sh

Reputation: 59

Can we access private document from google drive in iOS?

I am working on google drive api for fetching user's images/photos. But i am getting only public photos of user not Private. Can you please tell me is it possible to fetch private photos too ?

Upvotes: 1

Views: 65

Answers (1)

Tapansinh Solanki
Tapansinh Solanki

Reputation: 194

I was trying the same and came up with the solution.

Please give permissions by adding scopes. private let scopes = [kGTLAuthScopeDrivePhotosReadonly, kGTLAuthScopeDriveReadonly]

Fetch Files:

let query = GTLQueryDrive.queryForFilesList()

    query.pageSize = 10
    query.q = "mimeType = 'image/png' or mimeType = 'image/jpeg' or mimeType = 'image/jpg'"
    query.fields = "nextPageToken, files"
    AppSingletonObj.service.executeQuery(
        query,
        delegate: self,
        didFinishSelector: "displayResultWithTicket:finishedWithObject:error:"
    )

for showing images in collection view, i used “file.thumbnailLink”

for fetching original images,

let fetcherURL = "https://www.googleapis.com/drive/v3/files/(file.identifier)?alt=media"

let fetcher = AppSingletonObj.service.fetcherService.fetcherWithURLString(fetcherURL)

            fetcher.beginFetchWithCompletionHandler({ (data, error) -> Void in
                if error == nil {
                    print("success")
                }
                else {
                    print("failure")
                }
            })

Upvotes: 1

Related Questions