public void setObject(String bucketName, String fileName, byte[] data) throws IOException {
setObject(bucketName, fileName, getMimeType(fileName), DEFAULT_ACL, DEFAULT_CACHE, data, DEFAULT_ENCODING);
}
public void setObject(String bucketName, String fileName, String mimeType, String permission, String cacheControl, byte[] data, String encoding) throws IOException {
FileWriteChannel writeChannel = null;
try{
writeChannel = createWritableFile(bucketName,fileName,mimeType,permission,cacheControl);
writeChannel.write(ByteBuffer.wrap(data), encoding);
} catch (IOException e) {
logger.warning("IOException: " + e);
e.printStackTrace();
throw e;
} finally {
try {
if(writeChannel != null && writeChannel.isOpen()) writeChannel.closeFinally();
} catch (IllegalStateException e) {
logger.warning("IllegalStateException: " + e);
} catch (IOException e) {
logger.warning("IOException: " + e);
}