Skip to content

Commit ef795f6

Browse files
刘斌刘斌
authored andcommitted
7.0 form fname
1 parent adc785a commit ef795f6

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

library/src/androidTest/java/com/qiniu/android/FormUploadTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ public void complete(String k, ResponseInfo rinfo, JSONObject response) {
267267

268268
Assert.assertEquals(info.toString(), expectKey, key);
269269
Assert.assertTrue(info.toString(), info.isOK());
270+
//上传策略含空格 \"fname\":\" $(fname) \"
271+
Assert.assertEquals(f.getName(), resp.optString("fname", "res doesn't include the FNAME").trim());
270272
Assert.assertNotNull(info.reqId);
271273
Assert.assertNotNull(resp);
272274
TempFile.remove(f);

library/src/androidTest/java/com/qiniu/android/TempFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static File createFile(int kiloSize) throws IOException {
1616
FileOutputStream fos = null;
1717
try {
1818
long size = (long) (1024 * kiloSize);
19-
File f = File.createTempFile("qiniu_" + kiloSize + "k", "tmp");
19+
File f = File.createTempFile("qiniu_" + kiloSize + "k", ".tmp");
2020
f.createNewFile();
2121
fos = new FileOutputStream(f);
2222
byte[] b = getByte(1024 * 4);

library/src/main/java/com/qiniu/android/http/HttpManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void multipartPost(URI uri, PostArgs args, ProgressHandler progressHandle
152152
}
153153
} else {
154154
try {
155-
mbuilder.addPart("file", args.file, args.mimeType, "filename");
155+
mbuilder.addPart("file", args.file, args.mimeType, args.fileName);
156156
} catch (IOException e) {
157157
completionHandler.complete(ResponseInfo.fileError(e), null);
158158
return;

library/src/main/java/com/qiniu/android/storage/FormUploader.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ private static void post(byte[] data, File file, String k, final UpToken token,
6666
args.fileName = "?";
6767
}
6868

69+
// data is null , or file is null
70+
if (file != null) {
71+
args.fileName = file.getName();
72+
}
73+
6974
params.put("token", token.token);
7075

7176
final UploadOptions options = optionsIn != null ? optionsIn : UploadOptions.defaultOptions();

0 commit comments

Comments
 (0)