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

Update REST API.md #133

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/REST API.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [Create webhook](#create-webhook-api-reference)
* [Update webhook](#update-webhook-api-reference)
* [Delete webhook](#delete-webhook-api-reference)
* [Document info](#document-info-api-reference)
* [Convert document](#convert-document-api-reference)
* [Document conversion job status](#document-conversion-job-status-api-reference)
* [Convert video](#convert-video-api-reference)
Expand Down
6 changes: 3 additions & 3 deletions Documentation/Upload API.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .auto,
Direct uploads work with background `URLSession`, so uploading will continue if the app goes to the background state. It supports files smaller than 100MB only

```swift
guard let url = URL(string: "https://source.unsplash.com/featured"),
guard let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/"),
let data = try? Data(contentsOf: url) else { return }

let task = uploadcare.uploadAPI.directUpload(files: ["random_file_name.jpg": data], store: .auto, metadata: ["someKey": "someMetaValue"]) { progress in
Expand All @@ -142,7 +142,7 @@ task.cancel()
Sometimes you don't want to have the secret key in your client app and want to get it from the backend. In that case, you can provide an upload signature directly:

```swift
guard let url = URL(string: "https://source.unsplash.com/featured"),
guard let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/"),
let data = try? Data(contentsOf: url) else { return }

let signature = UploadSignature(signature: "signature", expire: 1658486910)
Expand Down Expand Up @@ -203,7 +203,7 @@ The direct upload method works with background `URLSession`, so uploading will c
## Upload files from URLs ([API Reference](https://uploadcare.com/api-refs/upload-api/#operation/fromURLUpload/)) ##

```swift
guard let url = URL(string: "https://source.unsplash.com/featured") else { return }
guard let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/") else { return }

// Set parameters by accessing properties
let task1 = UploadFromURLTask(sourceUrl: url)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Check the [Upload API documentation](https://github.com/uploadcare/uploadcare-sw
Example of uploads:

```swift
guard let url = URL(string: "https://source.unsplash.com/featured") else { return }
guard let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/") else { return }
guard let data = try? Data(contentsOf: url) else { return }

// You can create an UploadedFile object to operate with it
Expand Down
2 changes: 1 addition & 1 deletion Sources/Uploadcare/UploadAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ extension UploadAPI {
///
/// Example:
/// ```swift
/// guard let url = URL(string: "https://source.unsplash.com/featured"),
/// guard let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/"),
/// let data = try? Data(contentsOf: url) else { return }
///
/// let onProgress: (Double)->Void = { (progress) in
Expand Down
2 changes: 1 addition & 1 deletion Sources/Uploadcare/models/upload/UploadedFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public class UploadedFile: Codable {
///
/// Example:
/// ```swift
/// let url = URL(string: "https://source.unsplash.com/featured")!
/// let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
/// let data = try! Data(contentsOf: url)
/// let fileForUploading = uploadcarePublicKeyOnly.file(fromData: data)
///
Expand Down
18 changes: 9 additions & 9 deletions Tests/UploadcareTests/RESTAPIIntegrationAsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test05_delete_file() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand All @@ -97,7 +97,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test06_batch_delete_files() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand All @@ -114,7 +114,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test07_store_file() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand All @@ -133,7 +133,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test08_batch_store_files() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -208,7 +208,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test13_copy_file_to_local_storage() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand All @@ -229,7 +229,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test14_copy_file_to_remote_storage() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -285,7 +285,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test19_document_conversion_and_status() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)
DLog("size of file: \(sizeString(ofData: data))")

Expand Down Expand Up @@ -374,7 +374,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
// func test21_storing_shoudBeStored() {
// let expectation = XCTestExpectation(description: "test21_storing_shoudBeStored")
//
// let url = URL(string: "https://source.unsplash.com/featured")!
// let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
// let data = try! Data(contentsOf: url)
// let file = uploadcare.file(fromData: data)
// let name = UUID().uuidString
Expand Down Expand Up @@ -562,7 +562,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
}

func test31_document_info() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)
DLog("size of file: \(sizeString(ofData: data))")

Expand Down
18 changes: 9 additions & 9 deletions Tests/UploadcareTests/RESTAPIIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test05_delete_file() {
let expectation = XCTestExpectation(description: "test5_delete_file")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -189,7 +189,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test06_batch_delete_files() {
let expectation = XCTestExpectation(description: "test6_batch_delete_files")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -224,7 +224,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test07_store_file() {
let expectation = XCTestExpectation(description: "test7_store_file")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -262,7 +262,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test08_batch_store_files() {
let expectation = XCTestExpectation(description: "test8_batch_store_files")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -421,7 +421,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test13_copy_file_to_local_storage() {
let expectation = XCTestExpectation(description: "test13_copy_file_to_local_storage")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -460,7 +460,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test14_copy_file_to_remote_storage() {
let expectation = XCTestExpectation(description: "test14_copy_file_to_remote_storage")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -583,7 +583,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test19_document_conversion_and_status() {
let expectation = XCTestExpectation(description: "test19_document_conversion_and_status")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -743,7 +743,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test21_storing_shoudBeStored() {
let expectation = XCTestExpectation(description: "test21_storing_shoudBeStored")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)
let file = uploadcare.file(fromData: data)
let name = UUID().uuidString
Expand Down Expand Up @@ -1009,7 +1009,7 @@ final class RESTAPIIntegrationTests: XCTestCase {
func test27_document_info() {
let expectation = XCTestExpectation(description: "test27_document_info")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
guard let data = try? Data(contentsOf: url) else {
XCTFail("Could not read data from URL")
return
Expand Down
8 changes: 4 additions & 4 deletions Tests/UploadcareTests/UploadAPIIntegrationAsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class UploadAPIIntegrationAsyncTests: XCTestCase {
}

func test02_DirectUploadInForeground_and_FileInfo() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand All @@ -62,7 +62,7 @@ final class UploadAPIIntegrationAsyncTests: XCTestCase {
}

func test03_MainUpload() async throws {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

// small file with direct uploading
Expand Down Expand Up @@ -96,7 +96,7 @@ final class UploadAPIIntegrationAsyncTests: XCTestCase {
}

func test05_createFilesGroup_and_filesGroupInfo_and_delegeGroup() async throws {
let url = URL(string: "https://source.unsplash.com/featured?\(UUID().uuidString)")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/?\(UUID().uuidString)")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -126,7 +126,7 @@ final class UploadAPIIntegrationAsyncTests: XCTestCase {

func test06_direct_upload_public_key_only() async throws {
// a small file that should be uploaded with multipart upload method
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)
let fileForUploading = uploadcarePublicKeyOnly.file(fromData: data)

Expand Down
16 changes: 8 additions & 8 deletions Tests/UploadcareTests/UploadAPIIntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test02_DirectUpload() {
let expectation = XCTestExpectation(description: "test02_DirectUpload")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -92,7 +92,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test03_DirectUploadInForeground() {
let expectation = XCTestExpectation(description: "test03_DirectUploadInForeground")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -121,7 +121,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test04_DirectUploadInForegroundCancel() {
let expectation = XCTestExpectation(description: "test04_DirectUploadInForegroundCancel")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand All @@ -147,7 +147,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test05_UploadFileInfo() {
let expectation = XCTestExpectation(description: "test05_UploadFileInfo")

let url = URL(string: "https://source.unsplash.com/featured?\(UUID().uuidString)")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/?\(UUID().uuidString)")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -180,7 +180,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
}

func test06_MainUpload_Cancel() {
let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

let expectation = XCTestExpectation(description: "test06_MainUpload_Cancel")
Expand Down Expand Up @@ -246,7 +246,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test08_fileInfo() {
let expectation = XCTestExpectation(description: "test08_fileInfo")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)

uploadcare.uploadAPI.directUploadInForeground(files: ["random_file_name.jpg": data], store: .doNotStore, { (progress) in
Expand Down Expand Up @@ -306,7 +306,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test10_createFilesGroup_and_filesGroupInfo_and_delegeGroup() {
let expectation = XCTestExpectation(description: "test10_createFilesGroup_and_filesGroupInfo")

let url = URL(string: "https://source.unsplash.com/featured?\(UUID().uuidString)")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/?\(UUID().uuidString)")!
let data = try! Data(contentsOf: url)

DLog("size of file: \(sizeString(ofData: data))")
Expand Down Expand Up @@ -373,7 +373,7 @@ final class UploadAPIIntegrationTests: XCTestCase {
func test11_direct_upload_public_key_only() {
let expectation = XCTestExpectation(description: "test11_public_key_only")

let url = URL(string: "https://source.unsplash.com/featured")!
let url = URL(string: "https://ucarecdn.com/46528d0d-323c-42d7-beab-2fdc5e7077ba/")!
let data = try! Data(contentsOf: url)
let fileForUploading = uploadcarePublicKeyOnly.file(fromData: data)

Expand Down