// https://github.com/javaswift/joss/blob/master/src/main/java/org/javaswift/joss/model/StoredObject.java @Override public void storeFile(MultipartFile myFile, String fileId, int fileTTL) throws IOException { if (swiftUsername == null) { System.out.println("Swift username is not configured"); } assert swiftUsername != null; if (config == null) { login(); } StoredObject swiftObject = container.getObject(fileId); swiftObject.uploadObject(myFile.getInputStream()); if (myFile.getContentType() != null) { swiftObject.setContentType(myFile.getContentType()); } Map<String, Object> metadata = new HashMap<String, Object>(); if (myFile.getOriginalFilename() != null) { metadata.put("filename", myFile.getOriginalFilename()); } if (myFile.getContentType() != null) { metadata.put("content-type", myFile.getContentType()); } swiftObject.setMetadata(metadata); swiftObject.saveMetadata(); // swiftObject.setDeleteAt(Date date); }
@Test public void removeAndDoNotSaveMetadata() throws IOException { expectStatusCode(202); object.removeAndDoNotSaveMetadata("Year"); object.removeAndDoNotSaveMetadata("Company"); object.saveMetadata(); verifyHeaderValue("", X_OBJECT_META_PREFIX + "Year"); verifyHeaderValue("", X_OBJECT_META_PREFIX + "Company"); }
@Test public void setAndDoNotSaveMetadata() throws IOException { expectStatusCode(202); object.setAndDoNotSaveMetadata("Year", "1989"); object.setAndDoNotSaveMetadata("Company", "42 BV"); object.saveMetadata(); verifyHeaderValue("1989", X_OBJECT_META_PREFIX + "Year"); verifyHeaderValue("42 BV", X_OBJECT_META_PREFIX + "Company"); }