Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support google drive vid file download operation #2887

Open
SangeethaJanakiraman opened this issue Nov 21, 2024 · 4 comments
Open

Support google drive vid file download operation #2887

SangeethaJanakiraman opened this issue Nov 21, 2024 · 4 comments
Assignees
Labels
api: drive Issues related to the Drive API API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@SangeethaJanakiraman
Copy link

Does the SDK library support download API for long running operations?
https://developers.google.com/drive/api/reference/rest/v3/files/download

If not, is there a plan to add this support in near future ?

The documentation says that
The download() method is the only way to download Vids files in MP4 format and is typically best suited to downloading most video files
and hence export / get method cannot be used to download such files.

@SangeethaJanakiraman SangeethaJanakiraman added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 21, 2024
@amanda-tarafa
Copy link
Contributor

The Google.Apis.Drive.v3 exposes the file.download operation as defined by the the API.

As a side note, I couldn't find the docs from where you quoted the following, so I don't know if there's something else relevant there. Can you share a link to that?

The download() method is the only way to download Vids files in MP4 format and is typically best suited to downloading most video files

@SangeethaJanakiraman
Copy link
Author

I found that statement in this URL.
https://developers.google.com/drive/api/guides/long-running-operations#download-files

Sorry, I was looking at the old version of the source code and hence the issue. I could find it in latest version.
Thanks

@SangeethaJanakiraman
Copy link
Author

I am not able to cancel the download operation using operation Name.

Below is the flow.

  1. Initialized the DriveService object service as below
byte[] byteData = Encoding.UTF8.GetBytes(File.ReadAllText("C:\\gcreds.json"));
Stream jsonKeyStream = new MemoryStream(byteData);

ServiceAccountCredential keyLoader = ServiceAccountCredential.FromServiceAccountData(jsonKeyStream);
GoogleCredential genericCredential = GoogleCredential.FromServiceAccountCredential(keyLoader);
ServiceAccountCredential ImpersonatedServiceCredential = genericCredential.CreateWithUser(enduserSMTPsmtp)
                    .CreateScoped(new[] { DriveService.Scope.Drive})
                    .UnderlyingCredential as ServiceAccountCredential;

await ImpersonatedServiceCredential.GetAccessTokenForRequestAsync();
var service = new DriveService(new BaseClientService.Initializer()
{
    HttpClientInitializer = ImpersonatedServiceCredential,
});

  1. Submitting the download request succeeded and returned the Operation response with name and other details.
    var downloadReq = service.Files.Download(file.fileId) ;
    var operation = downloadReq.Execute() ;

  2. Getting cancelReq to cancel the operation if needed.
    var cancelReq = service.Operation.Cancel(operation.Name) ;

  3. After some time, I am calling cancelReq.Execute to cancel the download operation, but the call is failing with error

The service drive has thrown an exception. HttpStatusCode is Forbidden. The request is missing a valid API key. The service drive has thrown an exception.
HttpStatusCode is Forbidden.
Google.Apis.Requests.RequestError
The request is missing a valid API key. [403]
Errors [
Message[The request is missing a valid API key.] Location[ - ] Reason[forbidden] Domain[global]
]

Google.GoogleApiException: The service drive has thrown an exception. HttpStatusCode is Forbidden. The request is missing a valid API key.
at Google.Apis.Requests.ClientServiceRequest1.ParseResponse(HttpResponseMessage response) at Google.Apis.Requests.ClientServiceRequest1.Execute()

Can you help what is missing here?

@amanda-tarafa
Copy link
Contributor

Only the get operation is documented for the Drive Operation resource so I'm not sure you are meant to cancel them. The fact that we are generating a Cancel method in the library means that the cancel operation is specified on the discovery doc, but that may be explained away given that the Operation resource is a common resource used by many APIs. Even so, and as the operation.cancel documentantion states, I would have expected an UNIMPLEMENTED error.

This is all to say, I believe this is an issue with the API and not the library. I'll ask internally, but also please, raise the issue with the Drive API team by following one of their support routes

@amanda-tarafa amanda-tarafa added type: question Request for information or clarification. Not an issue. api: drive Issues related to the Drive API API. and removed type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: drive Issues related to the Drive API API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants