multipartform-data

Problems using multipart_encode (poster library)

一世执手 提交于 2019-12-07 15:44:27
I am trying to upload a file using multipart_encode to realize the MIME process. However, I met the following error AttributeError: multipart_yielder instance has no attribute '__len__' . Below are is my approach, I really appreciate if anyone can give me some suggestions. url = "https://pi-user-files.s3-external-1.amazonaws.com/" post_data = {} #data is a dict post_data['AWSAccessKeyId']=(data['ticket']['AWSAccessKeyId']) post_data['success_action_redirect']=(data['ticket']['success_action_redirect']) post_data['acl']=(data['ticket']['acl']) post_data['key']=(data['ticket']['key']) post_data[

javax.mail.internet.ParseException: In Content-Type string , expected '/', got :

别来无恙 提交于 2019-12-07 15:10:16
问题 I want to implement mail with attached file using JSF. I tried this code: private Part file; private String sendFromGMail(String from, String pass, String[] to, String subject, String body) { String status; Properties props = System.getProperties(); String host = "smtp.gmail.com"; props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", host); props.put("mail.smtp.user", from); props.put("mail.smtp.password", pass); props.put("mail.smtp.port", "587"); props.put("mail.smtp

Java - Upload OutputStream as HTTP File Upload

淺唱寂寞╮ 提交于 2019-12-07 14:28:21
问题 I've got a legacy application that writes to an OutputStream , and I'd like to have the contents of this stream uploaded as a file to a Servlet. I've tested the Servlet, which uses commons-fileupload , using JMeter and it works just fine. I would use Apache HttpClient, but it requires a File rather than just an output stream. I can't write a file locally; if there was some in-memory implementation of File perhaps that might work? I've tried using HttpURLConnection (below) but the server

Webflux multipart/form-data, csrf enabled, with and without file upload getting Invalid CSRF Token

佐手、 提交于 2019-12-07 14:22:46
问题 With csrf disabled I can upload file however I need it enabled. The problem only occurs when the form enctype is multipart/form-data, namely 'Invalid CSRF Token' with 403. Generally when I set the enctype as multipart/form-data even for a form without file upload, I get the same error. Using this dependency: <dependency> <groupId>org.synchronoss.cloud</groupId> <artifactId>nio-multipart-parser</artifactId> <version>...</version> </dependency> Tried including hidden csrf input in the form and

Content type for file part of the multipart/form-data request is set wrong by the client

*爱你&永不变心* 提交于 2019-12-07 12:43:18
问题 I'm trying to send multipart/form-data with following JavaScript and jQuery: var formData = new FormData(); formData.append("projectName", $("#projectNameInput").val()); var file = $("#fileInput")[0].files[0]; formData.append("content", file); var xhr = new XMLHttpRequest(); xhr.open('POST', '/project', true); xhr.onload = function(ev) { // Handling logic omitted }; xhr.send(formData); However, some client browsers (Firefox and Chrome) receive 400 Bad Request from the server. While examining

Posting `multipart/form-data` with Flurl

为君一笑 提交于 2019-12-07 10:26:48
问题 I am in need to post the following request: POST http://target-host.com/some/endpoint HTTP/1.1 Content-Type: multipart/form-data; boundary="2e3956ac-de47-4cad-90df-05199a7c1f53" Accept-Encoding: gzip, deflate Connection: Keep-Alive Content-Length: 6971 Host: target-host.com --2e3956ac-de47-4cad-90df-05199a7c1f53 Content-Disposition: form-data; name="some-label" value --2e3956ac-de47-4cad-90df-05199a7c1f53 Content-Disposition: form-data; name="file"; filename="my-filename.txt" <file contents>

How to get a MultipartHttpServletRequest from RequestContextHolder?

一世执手 提交于 2019-12-07 10:14:02
问题 I have configured the access decision manager to check a request before being processed by the servlet the key line is:- HttpServletRequest request = (HttpServletRequest) RequestContextHolder.currentRequestAttributes().getRequest(); All good. However when the request is enctype="multipart/form-data" how do I get hold of the MultipartHttpServletRequest when RequestContextHolder.currentRequestAttributes().getRequest() only returns HttpServletRequest ? I am using spring 2.5. 回答1:

Sending canvas.toDataURL() as FormData

你说的曾经没有我的故事 提交于 2019-12-07 08:17:40
问题 I am trying to use html2canvas to render a DOM element as a .png image, which I then want to upload to the server. Here is my code: import React, { Component, PropTypes } from 'react'; import html2canvas from 'html2canvas'; import axios from 'axios'; const sendScreenshot = (img) => { const config = { headers: { 'content-type': 'multipart/form-data' } } let data = new FormData(); data.append('screenshot', img); return axios.post('/api/upload', data) } export default class Export extends

How to upload an XML file using multipart/form-data with Restsharp?

拥有回忆 提交于 2019-12-07 07:52:28
Question: How to upload an XML file using multipart/form-data with Restsharp? Problem: I'm using Peppol for sending invoices using the Codabox API. I want to upload an xml to the rest service. The rest service itself is under control by the provider Codabox. I have 2 methods provided who I expect to do the same. First of all with Postman and httpclient, all the things works fine. I want to get the same from the httpclient method working using the restsharp way. RestSharp version: 106.2.1 Error message with Restsharp response = "StatusCode: BadRequest, Content-Type: application/json, Content

Retrofit for android @Multipart remove default headers

▼魔方 西西 提交于 2019-12-07 07:37:37
问题 Making a @Multipart request adds these default headers (Content-Transfer-Encoding, Content-Type) for each part, is there any way to remove them? //REQUEST BODY --25d35373-d2c3-46a3-969f-f5a1fd5f781a Content-Disposition: form-data; name="client_id" Content-Transfer-Encoding: binary <-- remove this one Content-Type: application/json; charset=UTF-8 <-- remove this one Content-Length: 34 "40ccfee680a844780a41fbe23ea89934" // NOTE: I do not have access to the server so there is no way I will be