How I export files from Google drive with C#.

  Рет қаралды 9,821

DAIMTO Developer Tips

DAIMTO Developer Tips

Күн бұрын

Пікірлер: 34
@boosterfnbr984
@boosterfnbr984 3 жыл бұрын
hey, I have a question about the upload funktion that I made. It is written in python and can upload files to drive, but I need to use the access token as Verifcation in it. However, as we all know the acess token stops working after one hour. Is there a way to automaticly refresh this token in the script, maybe with an variable and the refresh token? Thanks for your helping Content!
@DaimtoAps
@DaimtoAps 3 жыл бұрын
If you request offline access you should get a refresh token. The python client library should be able to handle refreshing the access token for you.
@nichlaus
@nichlaus Жыл бұрын
Hello... What should I change for the code to download all the text files in the folder?
@DaimtoAps
@DaimtoAps Жыл бұрын
you should do a file.list with q parameter and search for text files. Then do a file.get on each file to download it.
@brucelittle3248
@brucelittle3248 2 жыл бұрын
Can this be used in a Team Drive environmnet? I've now tested the Service Account granted us by our IT department on my personal (within work domain) drive and it does log in and return results. HOWEVER, if I try to retrieve files from a Shared Drive (and set the IncludeItemsFromAllDrives and SupportsAllDrives parameters on the request to true), it doesn't return an error, but it also returns no files or folders (and there are thousands on the Shared Drive). Are there other parameters that need to be set in order for it to return files from a Shared Drive?
@DaimtoAps
@DaimtoAps 2 жыл бұрын
Teams is workspace isn't it? check domain wide deligation
@brucelittle3248
@brucelittle3248 2 жыл бұрын
@@DaimtoAps Domain was fine. I tested it by modifying it to look at my personal drive (within the organization's Drive envirnoment) and it worked fine. HOWEVER -- the syntax in the Q parameter appears to be different for team drives. I found a Python example where they had "'' in parents" rather than "parents in ''". Changing it to this syntax worked. I'm not sure why there would be a discrepency in syntax between personal and Workspace Shared drives, but this appears to have been the issue. Also, the IncludeItemsFromAllDrives and SupportsAllDrives request parameters are 'false' by default and need to be set to 'true'.
@michellemontgomery5678
@michellemontgomery5678 2 жыл бұрын
Hey Linda! So I'm trying to download a file via export but the mimeType returned by get() isn't the same as what export expects so it says there is an error with file conversion. The file is a document created on Google Drive. The mimeType returned by get() is application/vnd.google-apps.document but export fails because it wants application/vnd.oasis.opendocument.text. I'm using the PHP api library. If you do an about request I see the JSON results with application/vnd.google-apps.document as a key to an array that contains application/vnd.oasis.opendocument.text. I want the file download mimeType to be automated. Any insight or recommendations? Thanks! :)
@DaimtoAps
@DaimtoAps 2 жыл бұрын
oh good question! can you put this on stack overflow with your code I would love to test this!
@sanskarrawat2750
@sanskarrawat2750 2 жыл бұрын
Hey, I have written my code using user account. But I want to run code on virtual machine so now I am making service account. But I couldn't find how to use service account in java and how can I access files through that service account. Please help me in this.
@DaimtoAps
@DaimtoAps 2 жыл бұрын
I don't have any java samples but I can definitely put something together
@osanbrazil999
@osanbrazil999 Жыл бұрын
How can I retrieve a directory's id by its name? e.g: I want to search files in a specific folder that I created in google drive, but I only have the name.
@DaimtoAps
@DaimtoAps Жыл бұрын
use file.list with the q parametre to Search by name and folder mime type
@GauravGurjar
@GauravGurjar 2 жыл бұрын
Can we download the files from multiple parent folders? For example, 2022 Folder > January > 01142022.csv 2022 Folder > February > 02142022.csv I have 2022 (year) as a grandparent and January(month) as a parent folder and 02142022.csv as child file. how to download the files every month which arrives every month. I can only give the folder id of 2022 hard-coded and month-based folder id has to be taken up automatically. Please guide.
@DaimtoAps
@DaimtoAps 2 жыл бұрын
your going to have to do it one at a time.
@StudentCompanion
@StudentCompanion 3 жыл бұрын
Thanks for the great video
@DaimtoAps
@DaimtoAps 3 жыл бұрын
hope I was able to help
@hernanrodriguezcatalano9997
@hernanrodriguezcatalano9997 3 жыл бұрын
can you export folders with all your files inside?
@DaimtoAps
@DaimtoAps 3 жыл бұрын
Sadly not in a single call, you will need to loop over each file and download them one at a time.
@rimeddahoumi4381
@rimeddahoumi4381 2 жыл бұрын
Thanks Linda for this great explaination ! So i would ask where can i find this script within the video 🙏🙏
@DaimtoAps
@DaimtoAps 2 жыл бұрын
Check the description I normally put up a companion blog post on my website with the code. www.daimto.com/google-drive-api-with-a-service-account/ Plan is to have a Patron account where I can give them access to full working samples. Something for the future.
@rimeddahoumi4381
@rimeddahoumi4381 2 жыл бұрын
@@DaimtoAps thank u very much Linda❤❤
@CarlosDiaz-tz6ov
@CarlosDiaz-tz6ov 2 жыл бұрын
Is there a way to export a specific file with the name?
@DaimtoAps
@DaimtoAps 2 жыл бұрын
No you will need to find that file.id, do a file.list and search for it
@abobrhom7
@abobrhom7 3 жыл бұрын
System.InvalidOperationException: 'Error creating credential from JSON. Unrecognized credential type .' I chose Desktop App as application type for the service account
@DaimtoAps
@DaimtoAps 3 жыл бұрын
you should create service account credentials not desktop credentials
@abobrhom7
@abobrhom7 3 жыл бұрын
@@DaimtoAps solved it days ago. Thank you
@mehmetalioran2721
@mehmetalioran2721 2 жыл бұрын
var response = await request.ExecuteAsync(); error is here
@DaimtoAps
@DaimtoAps 2 жыл бұрын
is your method set to async? what's your error?
@softfiscalpb674
@softfiscalpb674 3 жыл бұрын
Obrigado por compartilhar.
@mehmetalioran2721
@mehmetalioran2721 2 жыл бұрын
error? Severity Code Description Project File Line Suppression State Error CS4033 The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'. gdrv2 c:\users\oran\documents\visual studio 2015\Projects\gdrv2\gdrv2\Program.cs 35 Active
@DaimtoAps
@DaimtoAps 2 жыл бұрын
add async to your method declination
@germanlopez8649
@germanlopez8649 2 жыл бұрын
Amazing video! Greetings from Honduras!!! , but I'm having an error Unhandled exception. The service drive has thrown an exception. HttpStatusCode is BadRequest. Google.Apis.Requests.RequestError Invalid Value [400] Errors [ Message[Invalid Value] Location[q - parameter] Reason[invalid] Domain[global] ] Google.GoogleApiException: The service drive has thrown an exception. HttpStatusCode is BadRequest. Invalid Value Line Code: var responseSheet = await requestSheet.ExecuteAsync();
@DaimtoAps
@DaimtoAps 2 жыл бұрын
open a question on stack overflow if you want I will have a look
How I upload files to my google drive account with C#. #googledriveapi
12:46
DAIMTO Developer Tips
Рет қаралды 24 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Google’s Quantum Chip: Did We Just Tap Into Parallel Universes?
9:34
Don't Use AutoMapper in C#! Do THIS Instead!
16:17
Codewrinkles
Рет қаралды 71 М.
How to list all of your files on google drive with C#.  #googledriveapi
7:57
DAIMTO Developer Tips
Рет қаралды 12 М.
Gmail API using .NET C# with Source Code (Reading mails and Attachments)
45:58
Integrating Redux with React Native Expo
23:49
Ana's Dev Scribbles
Рет қаралды 52
Node.js File Upload to Google Drive: A Beginner's Tutorial  #googledriveapi
10:22