Ejemplo n.º 1
0
  // 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);
  }
Ejemplo n.º 2
0
 @Test
 public void setMetadata() throws IOException {
   expectStatusCode(202);
   Map<String, Object> metadata = new TreeMap<String, Object>();
   metadata.put("Year", "1989");
   metadata.put("Company", "42 BV");
   object.setMetadata(metadata);
   verifyHeaderValue("1989", X_OBJECT_META_PREFIX + "Year");
   verifyHeaderValue("42 BV", X_OBJECT_META_PREFIX + "Company");
 }