@Override
 public Upload getById(String fileId) throws IOException {
   if (config == null) {
     login();
   }
   Upload uploadRec = new Upload();
   StoredObject swiftObject = null;
   try {
     swiftObject = container.getObject(fileId);
   } catch (Exception e) {
     throw new FileNotFoundException(fileId);
   }
   Map<String, Object> metadata = swiftObject.getMetadata();
   uploadRec.setExpires(swiftObject.getDeleteAtAsDate());
   uploadRec.setFilename((String) metadata.get("filename"));
   uploadRec.setContentType((String) metadata.get("content-type"));
   uploadRec.setSize(swiftObject.getContentLength());
   Date today = new Date(System.currentTimeMillis());
   if (uploadRec.getExpires() != null) {
     if (today.after(uploadRec.getExpires())) {
       throw new FileNotFoundException(fileId);
     }
   }
   uploadRec.setContentStream(swiftObject.downloadObjectAsInputStream());
   return uploadRec;
 }
 @Test
 public void getMetadata() throws IOException, DateParseException {
   expectStatusCode(202);
   prepareMetadata();
   assertEquals("1989", object.getMetadata().get("Year"));
   assertEquals("42 BV", object.getMetadata().get("Company"));
   assertEquals("Mon, 03 Sep 2012 05:40:33 GMT", object.getLastModified());
   assertEquals(
       DateUtils.parseDate("Mon, 03 Sep 2012 05:40:33 GMT"), object.getLastModifiedAsDate());
   assertEquals(654321, object.getContentLength());
   assertEquals("image/png", object.getContentType());
   assertEquals("cae4ebb15a282e98ba7b65402a72f57c", object.getEtag());
   assertEquals("1339429105", object.getDeleteAt());
   assertEquals(DateUtils.parseDate("Mon, 11 Jun 2012 15:38:25 GMT"), object.getDeleteAtAsDate());
 }