lib/dropbox/dropbox.rb in dropbox-0.0.9 vs lib/dropbox/dropbox.rb in dropbox-0.0.10
- old
+ new
@@ -16,10 +16,14 @@
@agent = Mechanize.new
@folder_namespace = folder_namespace.gsub(/^\//,"")
@logged_in = false
end
+ def agent
+ @agent
+ end
+
# Lists all the files and folders in a given directory
def index(path = "/")
login_filter
path = namespace_path(path)
@@ -77,16 +81,20 @@
return listing
end
# Downloads the specified file from DropBox
def show(path)
+ require 'pathname'
# change to before filter
login_filter
- path = namespace_path(path)
+ # round about way of getting the secure url we need
+ # path = namespace_path(path)
+ pathname = Pathname.new(path)
+ url = self.list(pathname.dirname.to_s).detect{ |f| f["name"] == pathname.basename.to_s }["url"]
#https://dl-web.dropbox.com/get/testing.txt?w=0ff80d5d&sjid=125987568
- @agent.get("https://dl-web.dropbox.com/get/#{path}").content
+ @agent.get(url).content
end
alias :get :show
# Creates a directory