Skydrive重命名文件夹

时间:2015-07-10 11:53:41

标签: ruby-on-rails-4 onedrive

我在我的rails应用程序中使用Skydrive gem。

重命名我写的文件夹

def renaming_folder
  client = Skydrive::Client.new(@@access_token)
  folder_id = params[:folder_id]
  # (url, {:body => options})
  # options = {name: "#{params[:rename_field]}"}
  puts "-------------------..."
  puts "#{params[:folder_id]}"
  client.get_skydrive_object_by_id(folder_id)

  # I believe issue comes from this line:
  folderObject = client.update_skydrive_object("#{params[:folder_id]}", options={name: "#{params[:rename_field]}"})

  redirect_to drive_show_path
end

但我收到http_error_400:错误请求错误。我正在

{"utf8"=>"✓",
 "authenticity_token"=>"BAYGFcb5/74c7RV5NH1u4DCAT1MqLvLCkp9F3Q/Fav+B2wdab4aE5LBJAVr90MMu0GbfFwHTuLyncFRWtGyYTA==",
 "rename_field"=>"weqweqwe",
 "folder_id"=>"folder.cecb8eb83d90dbeb.CECB8EB83D90DBEB!106",
 "commit"=>"Rename Folder"}

在我的参数中。

有人可以帮忙吗?寻找可靠和/或官方来源的答案。

当我添加放置时,我能够获得所有值。

1 个答案:

答案 0 :(得分:0)

HTTP 400错误表示服务器无法理解您的HTTP请求:http://pcsupport.about.com/od/findbyerrormessage/a/400error.htm

"#{params[:folder_id]}""#{params[:rename_field]}"是说出params[:folder_id]params[:rename_field]的必要方式,它们已经是字符串。

client.get_skydrive_object_by_id(folder_id).update(options={name: params[:rename_field]

您的解决方案应该是:

skydrive_folder = client.get_skydrive_object_by_id(folder_id) skydrive_folder.update(options = {name: params[:rename_field]})

供参考:http://www.rubydoc.info/gems/skydrive/1.2.0/Skydrive/Operations#update_skydrive_object-instance_method http://www.rubydoc.info/gems/skydrive/Skydrive/Folder#update-instance_method

源代码:

第119行:https://github.com/ronyv89/skydrive/blob/master/lib/skydrive/operations.rb

第44行:https://github.com/ronyv89/skydrive/blob/master/lib/skydrive/client.rb