0
我想送存儲在內部存儲(InternalStrorage/PDF/OCK.pdf)的Android使用凌空
我已經通過此功能,發送字符串數據使用的是Android亂射我的PHP服務器沒有問題的一個PDF文件發送PDF服務器:
private void upload(){
StringRequest stringRequest = new StringRequest(Request.Method.POST, UploadURL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
String Response = jsonObject.getString("response");
Toast.makeText(getApplicationContext(),Response, Toast.LENGTH_LONG).show();
selectedimage.setImageResource(0);
selectedimage.setVisibility(View.GONE);
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}
){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("date",DateFormat.getDateTimeInstance().format(new Date()).toString());
params.put("description",editTextDescription.getText().toString());
params.put("statut", whatstatutis());
params.put("action",editTextImediatActionTaken.getText().toString());
return params;
}
};
MySingleton.getInstance(getApplicationContext()).addTorequesteque(stringRequest);
}
我想在同一時間用我的數據發送PDF文件。
嘗試使用多部分實體。文件可以使用多部分發送。 –
@AshishJohn你有一個很好的教程或有用的鏈接? –
也可以按照: 1.轉換PDF文件以字節數組 2.字節數組爲Base64編碼字節數組 字節[] encodedBytes = Base64.encodeBase64(origByteArr) 和 字符串base64Str =新字符串(encodedBytes); 使用任何可用的網絡庫發送它 – Napolean