Skip to content

Commit c7a972f

Browse files
author
彧贤
committed
support csv content type
1 parent c90f0dd commit c7a972f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/main/java/com/aliyun/oss/internal/Mimetypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public void loadMimetypes(InputStream is) throws IOException {
9090
}
9191
}
9292
}
93+
94+
extensionToMimetypeMap.put("csv", "text/csv");
9395
}
9496

9597
public String getMimetype(String fileName) {

src/test/java/com/aliyun/oss/integrationtests/PutObjectTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,5 +494,25 @@ public void testIncorrentSignature() throws Exception {
494494
}
495495
}
496496
}
497-
497+
498+
@Test
499+
public void testPutCSVTypeFile() throws Exception {
500+
final String key = "1.csv";
501+
final int instreamLength = 128 * 1024;
502+
503+
InputStream instream = null;
504+
try {
505+
instream = genFixedLengthInputStream(instreamLength);
506+
ossClient.putObject(bucketName, key, instream);
507+
508+
OSSObject o = ossClient.getObject(bucketName, key);
509+
Assert.assertEquals(o.getObjectMetadata().getContentType(), "text/csv");
510+
} catch (Exception e) {
511+
Assert.fail(e.getMessage());
512+
513+
if (instream != null) {
514+
instream.close();
515+
}
516+
}
517+
}
498518
}

0 commit comments

Comments
 (0)