1
我如何使用排球庫從移動設備發送文件(數據)到服務器。如何在android中將文件上傳到服務器?
這裏我列出了我的參數,請幫我解決這個問題。
Map<String, String> mHeaderPart= new HashMap<>();
mHeaderPart.put("Content-type", "multipart/form-data;");
mHeaderPart.put("Authorization", authorizationKey);
//String part
Map<String, String> mStringPart= new HashMap<>();
mStringPart.put("candidate_id", SessionStores.getBullHornId(getActivity()));
mStringPart.put("externalID", "portpolio");
mStringPart.put("fileCount", "2");//number of files
mStringPart.put("fileType", "SAMPLE");
mStringPart.put("platform", "android");
//file param
Map<String, File> mFilePartData= new HashMap<>();
在上面的文件參數中,我必須添加n個文件並將其發送到服務器。我如何從設備獲取文件,並添加n個文件與param並將其發送到服務器,如果有人可以請給我建議。
如果有人有使用抽球發送多個文件與param的例子,請指導我。提前致謝。
可能重複[如何使用Volley庫上傳圖像?](http://stackoverflow.com/questions/27112694/how-to-do-upload-image -with-volley-library) – Nitesh
結帳例如[Stackoverflow Link](http:// stackoverfl ow.com/questions/16797468/how-to-send-a-multipart-form-data-post-in-android-with-volley)(http://stackoverflow.com/questions/32262829/how -to-upload-file-using-volley-library-in-android) – mpals
感謝您的回覆@Nitesh,mplas。我懷疑如何發送filecontent參數作爲一個數組發送多個文件。像filecontent0,filecontent1 /這裏filecontent是文件參數添加文件。 – karthik