Xamarin.Auth 1.5.0: Google Drive: Cannot Name or Update Uploaded File?

124 Views Asked by At

I have successfully uploaded and downloaded files and downloaded files metadata from OneDrive and Dropbox using Xamarin.Auth 1.5. I have done all of this for Google Drive except when I upload a file I cannot name the file (shows as Untitled) and I cannot update the file once it is uploaded.

Below is code for uploading a file (creating) initially: Data for the file is in stream. Scope is https://www.googleapis.com/auth/drive.

URI uri = new Uri("https://www.googleapis.com/upload/drive/v3/files?uploadType=media"); OAuth2Request requestUpload = new OAuth2Request("POST", uri, null, (Account)authAccount); requestUpload.AddMultipartData("body", stream, "application/json", dataFileName); var responseUpload = await requestUpload.GetResponseAsync();

To update the file, I have tried adding the fileid to the url after files (e.g. files/fileid) and I received System.Net.HttpStatusCode.NotFound and I know that the fileid is correct because I was able to download the file using the same fileid. With the fileid, I also tried to use method PATCH but I received a Xamarin.Auth error.

To rename the file, I have tried using two AddMultipartData, one for data and the other for metadata (name) with correct formatting and all of the AddMultipartData metadata is added inside the file with the body data. I tried adding both data and metadata in one AddMultipartData with the same result as using two.

For both rename and update, I have tried all types of combinations, e.g. different uploadTypes, without /upload, method PUT, IDictionary parameters, just to name a few.

Does anyone know how to do this? Thanks for any help or suggestions.

1

There are 1 best solutions below

1
On

Xamarin.Auth has little to do with google drive APIs. It merely gets token for you.

All I can think of is that Xamarin.Auth intercepted some exception during PATCh and re-throw as Xamarin.Auth exception.

I suggest - issue on github. And ping me in community slack.