- Common ways to obtain Content
private void myMethod () {Content c =
Blob blob;Asset asset;new Content(new BlobPayload(blob, asset.requireContentType()))
- Smart code suggestions by Codota
}
@Transactional(retryOn = { ONeedRetryException.class }) @Override public void createSnapshot(String id, SnapshotComponentSelector selector) throws IOException { StorageTx tx = UnitOfWork.currentTx(); StorageFacet storageFacet = facet(StorageFacet.class); Bucket bucket = tx.findBucket(getRepository()); Component component = tx.createComponent(bucket, getRepository().getFormat()).name(id); tx.saveComponent(component); for (SnapshotItem item : collectSnapshotItems(selector)) { String assetName = createAssetPath(id, item.specifier.path); Asset asset = tx.createAsset(bucket, component).name(assetName); try (final TempBlob streamSupplier = storageFacet.createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) { AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null, FacetHelper.determineContentType(item), true); tx.attachBlob(asset, blob); } finally { item.content.close(); } tx.saveAsset(asset); } }