HTTParty:上传文件

时间:2018-03-17 13:56:44

标签: ruby-on-rails curl carrierwave httparty fog

如何使用HTTParty进行以下curl来电?

$ curl -u andrew.lunny@nitobi.com -F keystore=@android.keystore -F 'data={"title":"Android Key","alias":"release", "key_pw":"90123456","keystore_pw":"78901234"}' https://build.phonegap.com/api/v1/keys/android

以下是我目前的情况:

HTTParty.post("https://build.phonegap.com/api/v1/keys/android?auth_token=#{phonegap_token}", query: { keystore: file }, body: { data: {
    title: 'Android Key',
    alias: '...',
    key_pw: '...',
    keystore_pw: '...'
} }, format: :plain)

fileTempfile对象,我从文件所在的云存储中获取该对象。

我想传递一个使用Carrierwave上传并使用Fog存储的文件。我是否必须先从URL获取它?

1 个答案:

答案 0 :(得分:1)

我不确定它是否会起作用,但你可以尝试:

create function search_contacts
(_name text, _phone text, _email text, _address text, _threshold real)
  returns setof contact 
as $func$ 
declare
  _id uuid := uuid_generate_v4();
begin
  insert into _contact_index_tmp
    select...;
  insert into _contact_index_tmp
    select...;

  return query select c.* from _contact_index_tmp tmp left join 
  contact c
    on tmp.guid = c.contact_guid and tmp.query_id = _id;

  delete from _contact_index_tmp tmp 
  where tmp.query_id = _id;
  return;
end
$func$
language plpgsql;