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

Add zip download support #749

Merged
merged 7 commits into from
Jan 26, 2021
Merged

Add zip download support #749

merged 7 commits into from
Jan 26, 2021

Conversation

swfree
Copy link
Contributor

@swfree swfree commented Jan 12, 2021

Goals ⚽

  • Add support for zip download functionality

Implementation Details 🚧

  • Users can now create and download zip files by calling client.files.downloadZip(name:items:destinationURL:completion:).

Testing Details 🔍

  • Added unit tests & tested manually

@box box deleted a comment from swfree Jan 12, 2021
@box box deleted a comment from swfree Jan 12, 2021
Sources/Responses/ZipDownload.swift Outdated Show resolved Hide resolved
Sources/Modules/FilesModule.swift Outdated Show resolved Hide resolved
Sources/Modules/FilesModule.swift Show resolved Hide resolved
Sources/Modules/FilesModule.swift Outdated Show resolved Hide resolved
Sources/Responses/ZipDownload.swift Outdated Show resolved Hide resolved
/// - name: The name of the zip file to be created
/// - items: Array of files or folders to be part of the created zip
/// - completion: Returns a standard ZipDownload object or an error
public func createZip(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this private to match the implementation in Python and .Net SDKs? The idea is to offer just one method that simply does the download and sends back a "combined response."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

@@ -520,3 +520,59 @@ client.files.listRepresentations(
```

[get-representations]: https://opensource.box.com/box-ios-sdk/Classes/FilesModule.html#/s:6BoxSDK11FilesModuleC19listRepresentations6fileId18representationHint10completionySS_AA018FileRepresentationJ0OSgys6ResultOySayAA0lM0VGAA0A8SDKErrorCGctF

Create Zip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per comment above, let's make Create Zip private, so this section can be removed.

@@ -1875,6 +1875,122 @@ class FilesModuleSpecs: QuickSpec {
})
}

describe("createZip()") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per comment above, let's make Create Zip private, so this test can be removed.

sujaygarlanka
sujaygarlanka previously approved these changes Jan 20, 2021
@@ -164,6 +164,21 @@ class BoxJSONDecoder {
return color
}

static func optionalDecodeZip<T>(json: [[String: Any]]) throws -> T? where T: BoxModel {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool, BTW! Good job!

@@ -28,6 +28,7 @@ file's contents, upload new versions, and perform other common file operations
- [Set Shared Link](#set-shared-link)
- [Remove Shared Link](#remove-shared-link)
- [Get Representations](#get-representations)
- [Download Zip](#download-zip)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can roll back this commit. Running Jazzy Docs during the release will auto generate this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this one in since it doesn't seem like jazzy updates this, but if jazzy makes a duplicate during the release process I can delete it then

@@ -553,3 +554,5 @@ client.files.downloadZip(name: name, items: items, destinationURL: destinationUR
print("Zip download status: \(zipDownloadStatus.state)")
}
```

[download-zip]: https://opensource.box.com/box-ios-sdk/Classes/FilesModule.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can roll back this commit. Running Jazzy Docs during the release will auto generate this.


switch zipDownloadResult {
case .success:
self.getZipDownloadStatus(statusURL: zip.statusUrl, completion: completion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to combine this with zip.nameConflicts, returned from the call to createZip, so that callers to downloadZip get back both the download status AND the name conflicts (since we made createZip private). You can follow the example in .Net.

PJSimon
PJSimon previously approved these changes Jan 26, 2021
Copy link
Contributor

@PJSimon PJSimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if you choose "commit suggestion" then I don't have to re-approve, but feel free to change it if you otherwise want to.

Sources/Responses/ZipDownloadStatus.swift Outdated Show resolved Hide resolved
@swfree swfree merged commit 7854224 into master Jan 26, 2021
@swfree swfree deleted the zip-download-support branch January 26, 2021 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants