我使用代码发送zip文件,效果很好:
$file = ''.$_SERVER['DOCUMENT_ROOT'].'/projects/file.zip';
$data = array(
"file" => new CURLFile($file),
"data" => '{"title":"Test"}'
);
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, 'https://example.com');
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_HTTPHEADER, array(
'Content-type: multipart/form-data;',
));
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
$final = curl_exec($handle);
$response = json_decode($final, true);
curl_close ($handle);
但是当我发送扩展名为.keystore的文件时,没有任何效果。我在服务器上没有收到错误。
如何正确发送此类文件?
答案 0 :(得分:1)
您可以尝试
@Service
public class Customer {
/** The soap GW endpoint. */
@Value("${soapGWEndpoint}")
private String soapGWEndpoint;
/** The soap GW app name. */
@Value("${soapGWApplName}")
private String soapGWAppName;
/** The soap GW user. */
@Value("${generic.user}")
private String soapGWUser;
/** The soap GW password. */
@Value("${generic.user.password}")
private String soapGWPassword;
public Customer () {
}
@PostConstruct
public void init() {
login(soapGWEndpoint, soapGWAppName, soapGWUser, soapGWPassword);
}
}