New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to upload multiple files as form-data #830
Comments
Hi @chebyte, I must confess I don't personally use the multipart upload middleware, however I'd try with the below: json = {
listing: {
tickets: [
{
row: 'X',
seat: '201',
name: 'file1'
},
{
row: 'X',
seat: '202',
name: 'file2'
}
]
}
}
payload = {
listing: JSON.dump(json),
file1: Faraday::UploadIO.new(file1_path, file1_content_type)
file2: Faraday::UploadIO.new(file2_path, file2_content_type)
}
conn = Faraday.new(url) do |f|
f.request :multipart
f.request :json
f.adapter :net_http
end
conn.post(path, payload) There will be some variables you'll need to set which I'm not able to infer: |
I understand that this issue has been closed, but please help with the issue I am having which is close to this one. Below is what I need to upload
Please note content type that the server receives is my current code looks like below: client = Faraday::Connection.new(url: BASE_URL) do |builder|
builder.use :cookie_jar
builder.use :multipart
builder.use :url_encoded
builder.adapter :net_http
end
message = {title: "title", body: "body of message", recipientIdList:[186554]}
payload = {message: JSON.dump(message}
response = @client.post(URL) do |request|
request.headers['Content-Type'] = 'multipart/form-data'
request.body = payload
end However, the response I get from the server is I tweaked the code little by little and tried again, and searched google for hours but could not find solution. |
hello there I need to upload using faraday the following example
how can be transcribe to faraday way?
thanks
The text was updated successfully, but these errors were encountered: