如何使用轨道api上的红宝石上传下拉框中的多部分文档。
def upload_passport
APP_KEY = 'INSERT_APP_KEY'
APP_SECRET ='INSERT_APP_SECRET'
flow = DropboxOAuth2FlowNoRedirect.new(APP_KEY, APP_SECRET)
authorize_url = flow.start()
file = open(params[:file])
response = client.put_file('/magnum-opus.txt', file)
puts "uploaded:", response.inspect
end
答案 0 :(得分:1)
每次运行方法时,都会将值重新分配给常量。红宝石不允许这样做。
APP_KEY = 'INSERT_APP_KEY'
APP_SECRET ='INSERT_APP_SECRET'
您可以在包含此方法的类中添加它:
class MyClass
APP_KEY = 'INSERT_APP_KEY'
APP_SECRET ='INSERT_APP_SECRET'
def upload_passport
flow = DropboxOAuth2FlowNoRedirect.new(APP_KEY, APP_SECRET)
authorize_url = flow.start()
file = open(params[:file])
response = client.put_file('/magnum-opus.txt', file)
puts "uploaded:", response.inspect
end
end