byte[] rawData = FileUtil.toByteArray(stream); // cache data
memcache.put(randomId, rawData);
logger.info("Cached uploaded file id : " + randomId + " with size = " + rawData.length);
CacheUploadResult result = AutoBeanUtil.newCacheUploadResult(Status.SUCCESS, randomId, item.getName(), rawData.length);
resultStr = AutoBeanUtil.encode(CacheUploadResult.class, result);
} finally {
stream.close();
}
}
} catch (FileUploadException e) {
CacheUploadResult result = AutoBeanUtil.newCacheUploadResult(Status.FAIL, null, null, null);
resultStr = AutoBeanUtil.encode(CacheUploadResult.class, result);
logger.log(Level.SEVERE, "failed to upload file", e);
}