Comments (10)
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.
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.
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.
UP.
Still having this issue.
from google-api-objectivec-client-for-rest.
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 thex-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.
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.
Hi,
Good that somebody is into this.
Thanks.
from google-api-objectivec-client-for-rest.
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.
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.
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)
- Upload creative files to CM360 HOT 1
- Documentation on changes with 2.0.0 HOT 5
- DCM API Assistance needed HOT 1
- How to specify application name for GTLRDriveService to use drive.file scope HOT 2
- SSL certification error/ localhost not secure HOT 1
- CM360 API Issue HOT 1
- GCM360 Python sample code not working HOT 5
- Insecure API when using in React Native iOS app HOT 1
- 404 /resumable/upload/drive/v3/files HOT 7
- Failed to upload file to Google Drive HOT 4
- Error while compiling HOT 2
- Configure range with multiple sheet HOT 2
- Discovery version added
- google_api_SWIFT_client_for_rest HOT 2
- Swift Package manager include redundant modules HOT 4
- https://github.com/google/google-api-objectivec-client-for-rest/issues/607#issue-1899632415
- -[GTLRService requestUserAgent] blocks the calling thread in GTMFetcherApplicationIdentifier() HOT 5
- How to add event with Objective-c. [GoogleAPIClientForREST/Calendar] HOT 1
- [Drive API] Error 400 when replacing existing file during upload since v3.5.0 HOT 1
- People API issue with multiple libraries in Podfile HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-api-objectivec-client-for-rest.