Giter Club home page Giter Club logo

ruby-box's People

Contributors

aleksclark avatar eliotk avatar jessemiller avatar kenclarktaylor avatar leviwilson avatar marknadig avatar michaelmaag avatar mike-yesware avatar ombr avatar rposborne avatar skalb avatar tmhedberg avatar zenchild avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-box's Issues

Folder upload_file method not working

I've got some code that looks like:

folder = client.folder_by_id(folder_id)
folder.upload_file(file_name, data)

And I'm getting an exception like Errno::ENAMETOOLONG: File name too long. It appears to be passing the data variable as the file name when creating a new file.

I've looked through the source for the upload_file method, and it looks okay, but I've also verified that file_name is just foo.csv so something's going awry.

Any ideas? Is the upload_file method available for use, or old dead code?

README.md is getting a bit hectic

The README.md file is getting a bit hectic, with all the features that have been added to ruby-box recently. We should swing back around and edit this sucker.

gzip issues

Anyone else running into issues w/ gzipped responses? Testing this out locally with Ruby 2.0.0p247 and is abending on refresh_token call (via oauth2 gem). c/f oauth-xx/oauth2#159

However, seems this should be handled further up (Net::HTTP, Faraday).

> 2.0.0-p247 :016 > client.root_folder
OAuth2::Error: <??
?@E?e?.D?ҝV*??c`????_??3Z??M-Z?????"yY??po?#6qՠ?b?L???}?H-\?r?hz%
??!????9S?L?r?Jz?}?|Q-i??zH???1?5h?ЊE?DF?3?yP??as?,? 51ѕq???pB#)??BD???b6L
                                                                          ??r??????aa??
    from /Users/marknadig/.rvm/gems/ruby-2.0.0-p247@kona/gems/oauth2-0.9.3/lib/oauth2/client.rb:137:in `get_token'
    from /Users/marknadig/.rvm/gems/ruby-2.0.0-p247@kona/gems/oauth2-0.9.3/lib/oauth2/access_token.rb:86:in `refresh!'
    from /Users/marknadig/.rvm/gems/ruby-2.0.0-p247@kona/gems/ruby-box-1.13.0/lib/ruby-box/session.rb:38:in `refresh_token'
    from /Users/marknadig/.rvm/gems/ruby-2.0.0-p247@kona/gems/ruby-box-1.13.0/lib/ruby-box/session.rb:81:in `request'

Similar issue here w/ oauth gem after updating to Ruby 2
http://www.extendi.it/blog/2013/12/02/6-oauth-gem-and-ruby-2-0-0

Slow when navigating folder structure

I've integrated this gem into my Rails 3 app and am experiencing a significant delay when pulling files/folders. Here's a specific example.

I'm populating a select box with a nested folder structure from Box. There are a total of 6 folders in my Box account - 3 top/root level and the other 3 are subfolders (see structure below). The ajax request which populates this select box takes 25-30 second to complete! Do you have any thoughts or suggestions? The performance issue isn't isolated just to this method. It's anytime I fetch and iterate over files or folders.

/
/Folder 1
/Folder 1/Nested folder 1-1
/Folder 1/Nested folder 1-2
/Folder 2
/Folder 3
/Folder 3/Nested folder 3-1

Here's the recursive method I'm using.

def folders_from_box(parent_folder_path = '/', recursive = true)
  folders = []

  if parent_folder_object = client.folder(parent_folder_path)
    folder_objects = parent_folder_object.folders
    if folder_objects.length > 0
      parent_folder_path += "/" unless parent_folder_path[-1] == "/"
      folder_objects.each do |folder_object|
        folder_path = parent_folder_path + folder_object.name
        folders << { id: folder_object.id, path: folder_path }
        folders += folders_from_box(folder_path) if recursive
      end
    end
  end

  return folders
end

Getting bad request for all calls after auth

After getting tokens, just as shown in Readme, when attempting any call (e.g. folders = client.root_folder.folders ) I get a Bad request for any API call:

`RubyBox::RequestError (

<title>400 Bad Request</title>

400 Bad Request


nginx ):`

code used (with the constants/variables set of course):

session = RubyBox::Session.new({
  client_id: BOX_CLIENT_ID,
  client_secret: BOX_CLIENT_SECRET,
  access_token: token
})


client = RubyBox::Client.new(session)

folders = client.root_folder.folders

Invalid argument when installing gem on Windows

excuse my ignorance as I'm new to Ruby and box but when I attempt to install this gem I get an error. What is the problem? thanks.

C:>gem install ruby-box
Fetching: httpauth-0.2.0.gem (100%)
Successfully installed httpauth-0.2.0
Fetching: multi_xml-0.5.3.gem (100%)
Successfully installed multi_xml-0.5.3
Fetching: oauth2-0.9.1.gem (100%)
Successfully installed oauth2-0.9.1
Fetching: ruby-box-1.2.0.gem (100%)
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument - C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/ruby-box-1.2.0/spec/fixtures/i☺ e?↨f§↓.jpg

There is no way to set the various timeouts on the Net::HTTP object created in RubyBox::Session which can result in hangs

I haven't experienced this with Box yet, but with Dropbox, I have experienced hangs in requests that fail to get responses. The dropbox gem also uses Net::HTTP which does not have open_timeout, ssl_timeout, or continue_timeout's set by default. I want to avoid the same issue with Box by setting appropriate timeouts on the Net::HTTP object (which has to be done after it is created, no global config is available to my knowledge from reading the ruby code)

Preferably, RubyBox::Session would allow me to pass through these various timeouts which would then be set on the http object in RubyBox::Session.request

NoMethodError on deleting a file

session = RubyBox::Session.new(
  :client_id => ENV['BOX_CLIENT_ID'],
  :client_secret => ENV['BOX_CLIENT_SECRET'],
  :access_token => ENV['BOX_ACCESS_TOKEN']
)
client = RubyBox::Client.new(session)
file = client.upload_file_by_folder_id(valid_local_file_path, 0)
client.file_by_id(file.id).delete

# NoMethodError: undefined method `[]=' for nil:NilClass
# .rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/ruby-box-1.15.0/lib/ruby-box/session.rb:120:in `handle_errors'

Task support

I didn't see support for tasks, so I thought I'd take a crack at it.

#100

Docs on refresh token usage could be clearer

It would be helpful to indicate in the docs that, when you're using the refresh token, you should construct the session with the original access token.

e.g.

require 'ruby-box'

session = RubyBox::Session.new({
  client_id: 'your-client-id',
  client_secret: 'your-client-secret'
})

session.refresh_token('your-refresh-token')

will not work while the following will

require 'ruby-box'

session = RubyBox::Session.new({
  client_id: 'your-client-id',
  client_secret: 'your-client-secret',
  access_token: 'original-access-token'
})

session.refresh_token('your-refresh-token')

How to logon without redirect_uri

Hello there!

I would like to know how to log on without the "redirect_uri" and get the token. It's for a command line application.

Thanks for all.

There is no way to access the http response code from RubyBox::ServerError

When uploading a file, if it fails because the account is full, a 507 response is returned. However all I can see is RubyBox::ServerError. I don't know if it was some other 5xx error or not. It would be good if the entire response was included in the exception so that consumers of the gem can inspect the response for things the gem hasn't done.

description update stop working.

So recently my integration's update description stop working. now when I try to update the description I get a "RubyBox::ItemNameInUse: Item with the same name already exists" I will take a look and see if I can give you a hand looking for this bug.

Are there any versions of RubyBox that support Ruby 1.8.7?

I am currently using RubyBox 1.4.0 but seem to be running into compatibility issues with Ruby 1.8.7, specifically around an Enumerator call on line 109 of item.rb.

Do any of the earlier versions of RubyBox work as - is with 1.8.7?

If not, any suggestions for a patch so I can successfully backport this gem for 1.8.7?

Thanks,
Wes

Make 'folder' method return root folder

The 'folder' method in the client should return the root folder if:

  • an empty string is passed in.
  • / is passed in.
  • nothing is passed in.

I was playing with the API yesterday and was wishing that it worked like this.

When token auto-refreshed, how does client know?

I'm trying to work through how a user would detect that a requested failed initially due to an expired token and a successful refresh took place, providing a new access_token and refresh_token that the client may want to save. Any thoughts?

My current approach is to subclass session and override refresh_token to save off new tokens after calling super. I didn't know if there was a better pattern for some how passing this in the config; e.g. a proc or...

Client#create_folder needs to handle RubyBox::ItemNameInUse

When used in a multiprocess application, there can be a race condition where two processes try to create the same folder. The second one can fail the folder.create_subfolder() call with RubyBox::ItemNameInUse.

The fix for this is to catch this exception and try to open the folder instead of creating it.

client.upload_file_by_folder_id does not overwrite existing file name

Using upload_file_by_folder_id with the default overwrite=true fails when an existing file is present in the Box upload folder.

ruby-box (1.14.0)

irb(main):011:0* client.upload_file_by_folder_id('<My\Dir', '123456')
RubyBox::RequestError: Method Not Allowed
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/session.rb:128:in handle_errors' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/session.rb:87:in request'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/session.rb:48:in get' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/item.rb:68:in reload_meta'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/item.rb:85:in method_missing' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/file.rb:54:in update_content'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/folder.rb:23:in upload_file' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/client.rb:140:in block in upload_file_to_folder'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/client.rb:139:in open' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/client.rb:139:in upload_file_to_folder'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/ruby-box-1.14.0/lib/ruby-box/client.rb:106:in upload_file_by_folder_id' from (irb):11 from C:/Ruby200/bin/irb:12:in

'

How do you force delete a folder that is not empty?

Hello,

I get a "Cannot delete - folder not empty error".

I want to know if there is a way to force delete a folder for convenience. I've checked the README.md, it didn't even have information on deleting a folder. Code sample would be appreciated.

Folder#copy_to

Does the API preclude us from being able to copy one folder to another? Just curious if this can be added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.