Skip to content

Commit 44ef4aa

Browse files
authored
feat(java): add regular upload with token with video id support
1 parent 3c721d5 commit 44ef4aa

File tree

3 files changed

+23
-69
lines changed

3 files changed

+23
-69
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@ The following is a set of guidelines for contributing to api.video and its packa
1717
- [Suggesting enhancements](#suggesting-enhancements)
1818
- [How do I submit a (good) enhancement suggestion?](#how-do-i-submit-a-good-enhancement-suggestion)
1919
- [Pull requests](#pull-requests)
20-
- [Style guides](#style-guides)
21-
- [Git commit messages](#git-commit-messages)
22-
- [Documentation style guide](#documentation-style-guide)
2320
- [Additional notes](#additional-notes)
24-
- [Issue and pull request labels](#issue-and-pull-request-labels)
21+
- [Issue labels](#issue-labels)
2522
- [Type of issue and issue state](#type-of-issue-and-issue-state)
2623
- [Topic categories](#topic-categories)
27-
- [Pull request labels](#pull-request-labels)
28-
24+
2925
## Code of conduct
3026

31-
This project and everyone participating in it is governed by the [api.video Code of Conduct](https://github.com/apivideo/.github/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [help@api.video](mailto:help@api.video).
27+
This project and everyone participating in it is governed by the [api.video Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [help@api.video](mailto:help@api.video).
3228

3329
## I just have a question!
3430

@@ -104,55 +100,15 @@ Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com
104100

105101
### Pull requests
106102

107-
The process described here has several goals:
108-
109-
- Maintain api.video's quality
110-
- Fix problems that are important to users
111-
- Engage the community in working toward the best possible api.video
112-
- Enable a sustainable system for api.video's maintainers to review contributions
113-
114-
Please follow these steps to have your contribution considered by the maintainers:
115-
116-
1. Explain what, why and how you resolved the issue. If you have a related issue, please mention it.
117-
2. Follow the [style guides](#style-guides)
118-
3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing <details><summary>What if the status checks are failing?</summary>If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.</details>
119-
120-
While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted.
121-
122-
## Style guides
123-
124-
### Git commit messages
125-
126-
* Use the present tense ("Add feature" not "Added feature")
127-
* Limit the first line to 72 characters or less
128-
* Reference issues and pull requests after the first line
129-
* Consider starting the commit message with an applicable emoji:
130-
* :art: `:art:` when improving the format/structure of the code
131-
* :racehorse: `:racehorse:` when improving performance
132-
* :non-potable_water: `:non-potable_water:` when plugging memory leaks
133-
* :memo: `:memo:` when writing docs
134-
* :penguin: `:penguin:` when fixing something on Linux
135-
* :apple: `:apple:` when fixing something on macOS
136-
* :checkered_flag: `:checkered_flag:` when fixing something on Windows
137-
* :bug: `:bug:` when fixing a bug
138-
* :fire: `:fire:` when removing code or files
139-
* :green_heart: `:green_heart:` when fixing the CI build
140-
* :white_check_mark: `:white_check_mark:` when adding tests
141-
* :lock: `:lock:` when dealing with security
142-
* :arrow_up: `:arrow_up:` when upgrading dependencies
143-
* :arrow_down: `:arrow_down:` when downgrading dependencies
144-
* :shirt: `:shirt:` when removing linter warnings
145-
146-
### Documentation style guide
147-
148-
* Use [Markdown](https://daringfireball.net/projects/markdown).
149-
103+
Since this API client is generated from an OpenAPI description, we cannot accept pull requests made directly to the repository.
104+
If you want to contribute, you can open a pull request on the repository of our [client generator](https://github.com/apivideo/api.video-api-client-generator).
105+
Otherwise, you can also simply open an issue detailing your need on this repository.
150106

151107
## Additional notes
152108

153-
### Issue and pull request labels
109+
### Issue labels
154110

155-
This section lists the labels we use to help us track and manage issues and pull requests on all api.video repositories.
111+
This section lists the labels we use to help us track and manage issues on all api.video repositories.
156112

157113
[GitHub search](https://help.github.com/articles/searching-issues/) makes it easy to use labels for finding groups of issues or pull requests you're interested in. We encourage you to read about [other search filters](https://help.github.com/articles/searching-issues/) which will help you write more focused queries.
158114

@@ -188,15 +144,6 @@ This section lists the labels we use to help us track and manage issues and pull
188144
| `ui` | [search][search-apivideo-org-label-ui] | Related to visual design. |
189145
| `api` | [search][search-apivideo-org-label-api] | Related to api.video's public APIs. |
190146

191-
#### Pull request labels
192-
193-
| Label name | `apivideo` :mag_right: | Description
194-
| --- | --- | --- |
195-
| `work-in-progress` | [search][search-apivideo-org-label-work-in-progress] | Pull requests which are still being worked on, more changes will follow. |
196-
| `needs-review` | [search][search-apivideo-org-label-needs-review] | Pull requests which need code review, and approval from maintainers or api.video team. |
197-
| `under-review` | [search][search-apivideo-org-label-under-review] | Pull requests being reviewed by maintainers or api.video team. |
198-
| `requires-changes` | [search][search-apivideo-org-label-requires-changes] | Pull requests which need to be updated based on review comments and then reviewed again. |
199-
| `needs-testing` | [search][search-apivideo-org-label-needs-testing] | Pull requests which need manual testing. |
200147

201148
[search-apivideo-org-label-enhancement]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aenhancement
202149
[search-apivideo-org-label-bug]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Abug
@@ -225,4 +172,4 @@ This section lists the labels we use to help us track and manage issues and pull
225172
[search-apivideo-org-label-requires-changes]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Arequires-changes
226173
[search-apivideo-org-label-needs-testing]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aneeds-testing
227174

228-
[help-wanted]:https://github.com/search?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted+user%3Aapivideo+sort%3Acomments-desc
175+
[help-wanted]:https://github.com/search?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted+user%3Aapivideo+sort%3Acomments-desc

Sources/APIs/VideosAPI.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ The latter allows you to split a video source into X chunks and send those chunk
217217
- parameter completion: completion handler to receive the data and the error objects.
218218
*/
219219
@discardableResult
220-
open class func uploadWithUploadToken(token: String, file: URL, onProgressReady: ((Progress) -> Void)? = nil, apiResponseQueue: DispatchQueue = ApiVideoUploader.apiResponseQueue, completion: @escaping ((_ data: Video?, _ error: Error?) -> Void)) throws -> RequestTask {
220+
open class func uploadWithUploadToken(token: String, file: URL, videoId: String? = nil, onProgressReady: ((Progress) -> Void)? = nil, apiResponseQueue: DispatchQueue = ApiVideoUploader.apiResponseQueue, completion: @escaping ((_ data: Video?, _ error: Error?) -> Void)) throws -> RequestTask {
221221
if (try file.isMultiChunk) {
222-
return try UploadChunkRequestTaskQueue(token: token, file: file, onProgressReady: onProgressReady, apiResponseQueue: apiResponseQueue, completion: completion)
222+
return try UploadChunkRequestTaskQueue(token: token, file: file, videoId: videoId, onProgressReady: onProgressReady, apiResponseQueue: apiResponseQueue, completion: completion)
223223
} else {
224-
return uploadWithUploadTokenWithRequestBuilder(token: token, file: file, onProgressReady: onProgressReady).execute(apiResponseQueue) { result in
224+
return uploadWithUploadTokenWithRequestBuilder(token: token, file: file, videoId: videoId, onProgressReady: onProgressReady).execute(apiResponseQueue) { result in
225225
switch result {
226226
case let .success(response):
227227
completion(response.body, nil)
@@ -237,7 +237,7 @@ The latter allows you to split a video source into X chunks and send those chunk
237237
*
238238
- returns: a progressive uploadWithUploadToken session
239239
*/
240-
public class func buildProgressiveUploadWithUploadTokenSession(token: String) -> ProgressiveUploadWithUploadTokenSession {
240+
public class func buildProgressiveUploadWithUploadTokenSession(token: String, videoId: String? = nil) -> ProgressiveUploadWithUploadTokenSession {
241241
ProgressiveUploadWithUploadTokenSession(token: token)
242242
}
243243

@@ -247,8 +247,9 @@ The latter allows you to split a video source into X chunks and send those chunk
247247

248248
private let token: String
249249

250-
public init(token: String) {
250+
public init(token: String, videoId: String? = nil) {
251251
self.token = token
252+
self.videoId = videoId
252253
super.init(queueLabel: token)
253254
}
254255

@@ -286,7 +287,9 @@ The latter allows you to split a video source into X chunks and send those chunk
286287
let requestBuilder = uploadWithUploadTokenWithRequestBuilder(token: token, file: file, videoId: videoId, chunkId: partId, numOfChunks: numOfChunks, onProgressReady: onProgressReady)
287288
execute(requestBuilder, apiResponseQueue: apiResponseQueue) { data, error in
288289
if let data = data {
289-
self.videoId = data.videoId
290+
if self.videoId == nil {
291+
self.videoId = data.videoId
292+
}
290293
}
291294
completion(data, error)
292295
}

Sources/Upload/UploadChunkRequestTaskQueue.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class UploadChunkRequestTaskQueue: RequestTaskQueue<Video> {
5353

5454
internal convenience init(token: String,
5555
file: URL,
56+
videoId: String? = nil,
5657
onProgressReady: ((Progress) -> Void)? = nil,
5758
apiResponseQueue: DispatchQueue = ApiVideoUploader.apiResponseQueue,
5859
completion: @escaping (_ data: Video?, _ error: Error?) -> Void) throws {
@@ -65,6 +66,7 @@ public class UploadChunkRequestTaskQueue: RequestTaskQueue<Video> {
6566
requestBuilders.append(requestBuilder)
6667
}
6768
try self.init(requestBuilders: requestBuilders, fileSize: file.fileSize, queueLabel: token, onProgressReady: onProgressReady, apiResponseQueue: apiResponseQueue, completion: completion)
69+
self.videoId = videoId
6870
}
6971

7072
override func willExecuteRequestBuilder(requestBuilder: RequestBuilder<Video>) -> Void {
@@ -93,7 +95,9 @@ public class UploadChunkRequestTaskQueue: RequestTaskQueue<Video> {
9395
completion(nil, error)
9496
}
9597
} else {
96-
videoId = data?.videoId
98+
if (videoId == nil) {
99+
videoId = data?.videoId
100+
}
97101
if (requestBuilders.allSatisfy {
98102
$0.requestTask.state == .finished
99103
}) {

0 commit comments

Comments
 (0)