@Override public ISObject setAttribute(String key, String val) { return sobj.setAttribute(key, val); }
private void type(String type) { sobj.setAttribute(CONTENT_TYPE, type); }
public Blob(File inputFile, String type) { sobj = SObject.valueOf(NULL_KEY, inputFile); if (S.empty(type)) { type = MimeTypes.probe(inputFile); } if (S.notEmpty(type)) { type(type); } sobj.setAttribute(FILENAME, inputFile.getName()); }
@Override public ISObject get(String key) { GridFSDBFile file = findFile(key); if (null == file) { // try legacy file = findFile(BlobStorageService.getLegacyKey(key)); if (null != file) { Logger.warn("You have legacy blob data, please consider migrating them to new version"); } } if (null == file) { return null; } ISObject sobj = SObject.of(key, IO.readContent(file.getInputStream())); String fn = file.getFilename(); if (S.empty(fn)) { fn = S.random(8); } String type = file.getContentType(); if (S.empty(type)) { type = "application/octet-stream"; } return sobj.setAttribute(Blob.FILENAME, fn) .setAttribute(Blob.CONTENT_TYPE, type); }