8000 Add keywords to handle additional fields in API response by alextsui05 · Pull Request #3 · R167/backblaze · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add keywords to handle additional fields in API response #3

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

alextsui05
Copy link

Thank you for your work on this useful gem!

I was testing out the API and was getting some errors where there were more keys being passed to the constructor of B2::Bucket and B2::File than expected. Maybe the response has gained a few new fields recently:

2.2.3 :006 > Backblaze::B2::Bucket.buckets
ArgumentError: unknown keywords: bucket_info, lifecycle_rules, revision
	from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:12:in `initialize'
	from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:151:in `new'
	from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:151:in `block in buckets'
	from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:149:in `map'
	from /home/atsui/work/b2/lib/backblaze/b2/bucket.rb:149:in `buckets'

I also added an alias to B2::Bucket#bucket_name because I was getting this error in B2::File#download_url

:015 > b
 => #<Backblaze::B2::Bucket:0x00000001ea99e8 ...> 
2.2.3 :016 > f
 => #<Backblaze::B2::File:0x00000001d9a480 ...> 
2.2.3 :017 > f.download_url bucket: b
NoMethodError: undefined method `name' for #<Backblaze::B2::Bucket:0x00000001ea99e8>
	from /home/atsui/work/b2/lib/backblaze/b2/file.rb:116:in `download_url'

While I was at it, I added a first_file keyword for B2::Bucket#file_names so you can search a bucket by filename.

By the way, I am working on a paperclip gem using the backblaze gem as a base, and I was stuck on how to provide support for creating B2::Files from Paperclip's file adapter. Let me know if you'd be interested, it would be great to have your feedback.

@R167
Copy link
Owner
R167 commented Jun 19, 2017

Thank you very much for this! I have really been meaning to get this gem to a stable and more compliant state, but over the last few months, life has been catching up with me. I'll absolutely look over this in the morning when I have time. Hopefully, it works with the changes I'd been testing in my general-refactoring branch. I would absolutely be interested in helping and also welcome any feedback you have on the direction in which this gem should be taken.

@alextsui05
Copy link
Author

@R167 Glad to hear your reply!

I'm trying to see how much work to fold in the commits from the general-refactoring branch. There's not too many conflicts, but I'm getting this error:

NameError: uninitialized constant Backblaze::B2::UrlManager::Singleton
	from /home/atsui/backblaze/lib/backblaze/b2/url_manager.rb:6:in `<class:UrlManager>'

Maybe there was a file that wasn't committed?

If you'd like, we can try to get the error squared away and I can do some tests, then I'll update my master branch so we can see all the changes at a glance here.

Remove :b2_bucket option, replace with `bucket` key in the credentials
file
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.

2 participants
0