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

refactor!: use bzz endpoint for file and dirs #280

Merged
merged 7 commits into from
May 5, 2021

Conversation

AuHau
Copy link
Contributor

@AuHau AuHau commented Apr 22, 2021

This PR adopts the upcoming changes to bee (see ethersphere/bee#1501). Also tackles partially the #265. It won't be merged atm. but it is ready for review.

Current limitation of this PR:

Breaking changes:

  • Removing download*FromCollection
  • Removed recursive flag from uploadFilesFromDirectory

@AuHau AuHau marked this pull request as ready for review April 22, 2021 13:38
@AuHau AuHau requested a review from nugaon as a code owner April 22, 2021 13:38
@AuHau AuHau requested a review from a team April 22, 2021 13:38
@AuHau AuHau force-pushed the refactor/adjust-to-new-bee-api branch 2 times, most recently from 396bdfc to 20cf6d5 Compare April 27, 2021 11:22
@AuHau AuHau force-pushed the refactor/adjust-to-new-bee-api branch from 20cf6d5 to 695e865 Compare April 28, 2021 07:17
@AuHau AuHau changed the base branch from master to bee-0.6.0 April 28, 2021 07:21
src/modules/bzz.ts Outdated Show resolved Hide resolved
src/modules/bzz.ts Outdated Show resolved Hide resolved
Copy link
Member

@nugaon nugaon left a comment

Choose a reason for hiding this comment

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

LGTM!

headers: {
...extractFileUploadHeaders(options),
},
params,
Copy link
Member

Choose a reason for hiding this comment

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

It's possible to rewrite this as

params: {
  name,
},

Then the params declaration above with the if (name) { ... } is not necessary.

@AuHau AuHau mentioned this pull request May 5, 2021
@AuHau AuHau merged commit 35779bb into bee-0.6.0 May 5, 2021
@AuHau AuHau deleted the refactor/adjust-to-new-bee-api branch May 5, 2021 08:09
name?: string,
options?: FileUploadOptions,
): Promise<Reference> {
if (!url) {
Copy link
Member

Choose a reason for hiding this comment

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

This check is not strictly necessary because uploadFile is not exposed to the public API, therefore it's always called with the inputs already validated.

We also doesn't check the inputs or the url in other functions. If you want stronger guarantees it's possible to create a BeeURL type which is already validated and have the type system enforce its validity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants