I'm using SkyDrive Live to upload files, but now I want to download the file I just uploaded. In the documentation it mentions a file ID but I'm not finding how I can get that ID.
I have a folder that I placed the file into so I would somehow need to pass the folder ID and then get the fileID...
Does anyone know how to do this or know of any tutorials on this?
If you uploaded the file with SkyDrive SDK, then you get the fileId by the UploadCompleted event's e.Result["id"]
If you have the folderId, but not the fileId, then you can query the content of the folder with client.GetAsync(folderId/files). The GetCompleted event's e.Result["data"] returns a IDictionary of file descriptions, each containing the fileId. In this cased you need to identify the required file by dictionaryEntry["name"] or some other magic..
Related
My question is similar to What is format of Google Drive's FileID ? I need to find out whether new File has been uploaded to my drive or not using API's but I want to know the format of a folder ID in Google Drive, the one that appears in the URL bar when you open a folder in your Google drive, the thing after https://drive.google.com/drive/u/0/folders/<this part>.
Google Drive folder id doesn't have a specific guaranteed format. This (apparent format which really isn't a format) has changed in the past and may change again.
Trying to create any kind of local verification of this will be futile.
The best option would be to do a Files: get and test if you get a response. This will work better as it will also verify that the user has access to the file as well as testing that its a valid file id format.
Any (regex) attempt to verify the file id wouldn't really verify it as its not going to test if the user has access.
A folder ID starts with a 1 followed by 32 base-64 encoded digits, except unlike base64 the + is replaced by - and / is replaced by _. You can use the following regex:
/^1[A-Za-z0-9-_]{32}$/
I'm trying to access a file in a Google Drive directory but linking to it using the File Id provided by the API it says that i don't have permission. What i saw is that the File Id in the URL is different from the one who returns from the API. Why?
Using the test page of the Google Api it returns a "Not Found" error(404) and not the "No Permissions" error. Anybody knows how to get this ID(same of the url) that links to the file instead of the File's ID
Edit: Found that the File Resource has a property called "webViewLink" is it the link to the file instead of using the ID?
When you are trying the Drive API, you can set using fields property what values you want to return from your call as it is shown in this image:
webViewLink will return you the link that's shown when you open the file in your browser.
id will return you the ID of the file.
I specified some values, but you can see HERE all the values you could use and if you put "*" you will return all of them. Also, I didn't show in the image the id of the file to not share that info.
HERE you can see why you are getting that error. Surely, you don't have enough permitions because you have already checked that it exists for what I understood in your question.
This is documentation which I'm using - https://developers.google.com/drive/api/v3/search-parameters
Does anyone know the way of getting through Google Drive API, the number of times the file was downloaded, views(ideal views by whom)...
I could not find any way of doing this.
Google drive files are denoted by a file resource this contains all the information that you have access to about the file. Only some of the information you are after is available
createdTime datetime The time at which the file was created (RFC 3339 date-time). writable
modifiedTime datetime The last time the file was modified by anyone (RFC 3339 date-time).
Note that setting modifiedTime will also update modifiedByMeTime for the user.
lastModifyingUser nested object The last user to modify the file.
You can see who last changed the file but you cant see who has seen the file or any information about how many times it was downloaded.
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.
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.
Am having some trouble with the SkyDrive download process and hoping you can help me.
Following the standard SkyDrive API & examples, I've set up a page that browses the SkyDrive folder structure, lets User click on a file, prompt to download, and it all works correctly.
Where I'm having trouble is when the file downloaded is large, I get the OutOfMemoryException thrown at around the 100Mb mark.
Dennis speaks on this problem here http://dotnet.dzone.com/articles/2-things-you-should-consider but it relates to a direct URL download, not via the SkyDrive architecture.
I've tried extracting the URL from SkyDrive and doing the direct download that way but haven't had any success.
Here is the code I'm using - the "item" object is of type SkyDriveItem, having iterated through a folders content and selected this file.
LiveConnectClient downloadClient = new LiveConnectClient(App.Session);
try
{
downloadClient.DownloadCompleted += new EventHandler<LiveDownloadCompletedEventArgs>(downloadClient_DownloadCompleted);
downloadClient.DownloadProgressChanged += new EventHandler<LiveDownloadProgressChangedEventArgs>(downloadClient_DownloadProgressChanged);
downloadClient.DownloadAsync(item.ID + "/content", item);
This will work fine when the file isn't too large, but as mentioned, select a big file (>100Mb) and it dies with the OutOfMemory exception.
Any pointers?
Thanks in advance
Resolved - While I was never able to use the downloadClient.DownloadAsync() method to download large files, playing with the downloadClient.getAsync() and using the Pre-Authenticated URL via a regular Stream downloader does the trick.