try
{
logger.info("Writing GridFS file: "+file.getAbsolutePath()
+ ", length: " + file.length()
+ ". Writing with chunk size: " + chunkSize);
GridFSInputFile gridFile = fs.createFile(file);
//Add user-defined properties
for (String key : properties.keySet())
{
gridFile.put(key, properties.get(key));
}
gridFile.put("timestamp", System.currentTimeMillis());
gridFile.put("uniqueId", UidGenerator.generateUid());
gridFile.setFilename(renameTo);
gridFile.save(chunkSize);
gridFile.validate();
}
catch(IOException e)
{
throw new DBException("Failed to read input file: "
+file.getAbsolutePath(), e);