Git Product home page Git Product logo

Comments (10)

thomasvl avatar thomasvl commented on September 1, 2024

It is going to be a little hard to figure out what's not working from the limited info you have provide. I believe resume was working last time we checked with the YouTube sample we provide. Can provide more info about how you are getting the URL and how you are trying to resume? The http log from the initial operation and of trying to resume it might also help.

from google-api-objectivec-client-for-rest.

okipol88 avatar okipol88 commented on September 1, 2024

Sorry for this limited info.
For more background I have been succesfully running V2 of the API. Then this appeared after the migration but I will provide more information (will turn the debug loggin on the fetcher and so on).

from google-api-objectivec-client-for-rest.

okipol88 avatar okipol88 commented on September 1, 2024

First I create a YouTube file:

GTLRYouTube_Video *video = [GTLRYouTube_Video object];
    GTLRYouTube_VideoSnippet *snippet = [GTLRYouTube_VideoSnippet object];
    GTLRYouTube_VideoStatus *status = [GTLRYouTube_VideoStatus object];
    status.privacyStatus = @"public";
    snippet.title = title;
    snippet.descriptionProperty = description;
    snippet.tags = tags;
    video.snippet = snippet;
    video.status = status;

Then I create the query:

        GTLRUploadParameters *uploadParameters = [GTLRUploadParameters uploadParametersWithFileURL:uploadFileURL MIMEType:@"video/*"];
        GTLRYouTubeQuery *query = [GTLRYouTubeQuery_VideosInsert queryWithObject:video part:@"snippet,status" uploadParameters:uploadParameters];
        uploadParameters.useBackgroundSession = self.usesBackgroundSession;

After this I attach the resume URL (if I have one):

 NSURL *uploadResumeUrl;
    if (attemptResume && userId.length > 0) {
        uploadResumeUrl = [self.uploadResumeInfoProvider uploadURLForResumableUploadOfFile:fileName forUserId:userId];
    }
    [query.uploadParameters setUploadLocationURL:uploadResumeUrl
];

To get the resume URL I use a notification:

[[NSNotificationCenter defaultCenter] addObserverForName:kGTMSessionFetcherUploadLocationObtainedNotification object:fetcher queue:nil usingBlock:^(NSNotification * _Nonnull note) {
            NSURL *uploadLoactionURL = fetcher.uploadLocationURL;
        }];

The URL looks like this:

https://www.googleapis.com/resumable/upload/youtube/v3/videos?part=snippet%2Cstatus&prettyPrint=false&upload_id=AEnB2Up1XkD6hFhaedccUe88PcK4J7eL2Le-qdl6kvaJK1vE2AjYUmj7oU1joczLwu6_ybZJf8pT6Lyw7fJVFnlM6zECWvVW4IfM2ntYsct5fffks8zB5_U&upload_protocol=resumable

As for the response I get from the HTTP Logging:

youtube.videos.insert (query offset)

2016-10-18 07:10:40 +0000  elapsed: 0.245sec
Request: PUT https://www.googleapis.com/resumable/upload/youtube/v3/videos?part=snippet%2Cstatus&prettyPrint=false&upload_id=AEnB2UoAVlgretPOe_t8Iiqat91EEvoy8ycIM0YY3deBC4UfhT7JcRwEuMfoiL5DovIAu6EoD8eoHRJXuO2gP1wv3jH7FY85qA&upload_protocol=resumable
Request headers:
  X-Goog-Upload-Command: query

Response: status 200
Response headers:
  Content-Length: 0
  Content-Type: text/html; charset=UTF-8
  Date: Tue, 18 Oct 2016 07:10:40 GMT
  Server: UploadServer
  alt-svc: quic=":443"; ma=2592000; v="36,35,34"
  x-goog-upload-status: cancelled
  x-guploader-uploadid: AEnB2UoAVlgretPOe_t8Iiqat91EEvoy8ycIM0YY3deBC4UfhT7JcRwEuMfoiL5DovIAu6EoD8eoHRJXuO2gP1wv3jH7FY85qA

Response body: (0 bytes)
-----------------------------------------------------------

In your example YouTubeSampleWindowController.m I did not see setting the _uploadLocationURL - I belive this is responsible for the resume in your code (not pause - resume, but resume for e.g. a broken download for which we do not have the Ticket anymore.
This code was running just fine in V2 thus my astonishment.

Furthermoe debugging shows that I get the error from:

GTMSessionUploadFetcher line 709

- (NSError *)prematureFailureErrorWithUserInfo:(NSDictionary *)userInfo {
  // An error for if we get an unexpected status from the upload server or
  // otherwise cannot continue.  This is an issue beyond the upload protocol;
  // there's no way the client can do anything useful except give up.
  NSError *error = [NSError errorWithDomain:kGTMSessionFetcherStatusDomain
                                       code:501  // Not implemented
                                   userInfo:userInfo];
  return error;
}

As a consequence of

  if (error == nil) {
    sizeReceivedHeader = [responseHeaders objectForKey:kGTMSessionHeaderXGoogUploadSizeReceived];

    if (uploadStatus == kStatusCancelled ||
        (uploadStatus == kStatusActive && sizeReceivedHeader == nil)) {
      NSDictionary *userInfo = nil;
      if (data.length > 0) {
        userInfo = @{ kGTMSessionFetcherStatusDataKey : data };
      }
      error = [self prematureFailureErrorWithUserInfo:userInfo];
    }
  }

I belive because the cancelled upload status in the response.

Perhaps the upload resume is not supported if it was cancelled explicitly by the client anymore? I belive the code worked in V2.

from google-api-objectivec-client-for-rest.

okipol88 avatar okipol88 commented on September 1, 2024

UP.
Still having this issue.

from google-api-objectivec-client-for-rest.

okipol88 avatar okipol88 commented on September 1, 2024

I investigated the V3 behavior further.
Up till now (V2) I have been canceling the ticket. I have no idea what response it gave back when calling the API on resume but I do recall it worked.

For V3 issuing the cancel on a ticked we get:

  • ticked is cancelled, the server somehow has the cancelled state and will respond when queried for the location with the x-goog-upload-status explicitly set to that value.
  • the video on the YouTube page will be in the state Preparing upload. and not cancelled (seems like I could still resume somehow...)

The solution to this state is to pause the ticket instead of cancelling.
Hope this is a valid and proper handling.

Re-creating the upload with the resume URL then works fine.

from google-api-objectivec-client-for-rest.

thomasvl avatar thomasvl commented on September 1, 2024

Sorry for not replying sooner. @sergiocampama is looking into this, he thinks there might be some things up, so he's revalidating things in general as well as specific to YouTube. But some other things have been competing for his time.

from google-api-objectivec-client-for-rest.

okipol88 avatar okipol88 commented on September 1, 2024

Hi,

Good that somebody is into this.
Thanks.

from google-api-objectivec-client-for-rest.

sergiocampama avatar sergiocampama commented on September 1, 2024

So I talked to the Youtube team, and it looks like cancel wasn't implemented in V2. That would explain why sending a cancel would do nothing and you could continue uploading.

How are you stopping the upload and getting the upload URL? It would really help seeing the whole logs from first and further attempts. (Also if you can do this for V2 that would be great too)

from google-api-objectivec-client-for-rest.

okipol88 avatar okipol88 commented on September 1, 2024

Sorry for the lack of response.

for the canceling I was doing:

GTLRServiceTicket *ticket = ...;
    [ticket cancelUpload]; 

Now I changed it to:

GTLRServiceTicket *ticket = ...;
    [ticket pauseUpload]; // Pause instead of cancel -> cancelling caused upload to not be resumable

As for obtaining the video location I was using:

... = [[NSNotificationCenter defaultCenter] addObserverForName:kGTMSessionFetcherUploadLocationObtainedNotification object:fetcher queue:nil usingBlock:^(NSNotification * _Nonnull note) {
            NSURL *uploadLoactionURL = fetcher.uploadLocationURL;
        }];

from google-api-objectivec-client-for-rest.

sergiocampama avatar sergiocampama commented on September 1, 2024

Hi, sorry for the late reply... After talking with the Youtube maintainers, I believe your suspicions are correct, in that V2 apparently ignored the cancel request, but V3 is enforcing it correctly. Using pause instead of cancel (as you mention) seems to be the best way forward.

from google-api-objectivec-client-for-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.