Can't download a Google drive file using WebClient

253 Views Asked by At

I'm trying to download a csv file from a Google drive using a vb.net app. This has worked fine for years, but today when I try to download using the app, I get a csv file that contains only this message: "Google Drive - Quota exceeded: you can't view or download this file at this time. Too many users have viewed or downloaded this file recently... " But that error message can't be accurate because when I try pasting the same url into a browser, the 1.3 MB csv file I want downloads without a problem.

I've tried specifying a User-Agent header to tell Google that I'm using a browser but no improvement.

Any idea why the download works from the browser but not from WebClient? Thanks!

My code is as follows:

Private Sub UpdateCatalog()
    Dim _WebClient As New System.Net.WebClient()
    _WebClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
    Dim url As String
    url = "https://drive.google.com/uc?export=download&id=1HDRnj41YBWpMioLPwAFiLlK4SK8NV72C"

    '   Check if the folder already exists; if not, create it
    If Not My.Computer.FileSystem.DirectoryExists(My.Settings.CatalogFolder) Then
        Try
            My.Computer.FileSystem.CreateDirectory(My.Settings.CatalogFolder)
        Catch Ex As Exception
            MsgBox("Could not create a folder to store the catalog file." & vbCr & Ex.Message,, "Folder Creation Error")
            Exit Sub
        End Try
    End If

    '   Check if the catalog file already exists; if so, delete it
    If My.Computer.FileSystem.FileExists(My.Settings.CatalogFile) Then My.Computer.FileSystem.DeleteFile(My.Settings.CatalogFile)

    '   Download the new file
    Try
        _WebClient.DownloadFile(url, My.Settings.CatalogFile)
    Catch ex As Exception
        MsgBox("Failed to download catalog file from Environment Canada." & vbCr & ex.Message, "Download Failure")
    End Try
End Sub
1

There are 1 best solutions below

0
Jordy On

Same issue here, used to work just fine. Trying to get the file using a FileStreamResult, only to receive the message Sorry, you can't view or download this file at this time. Too many users have viewed or downloaded this file recently.... Using the download url directly does download the file. However, using the url in a private window the same message is displayed again.

Perhaps a cookie issue related to this: https://workspaceupdates.googleblog.com/2023/10/upcoming-changes-to-third-party-cookies-in-google-drive.html

Or maybe a temporary Google issue?

Unfortunately have not found a solution yet.

Edit 15 feb.: It seems the files can be downloaded again, so I think it was a temporary Google issue.