public class AssetUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
REMOTE_FILE_NAME_DEFAULT |
| Constructor and Description |
|---|
AssetUtils() |
| Modifier and Type | Method and Description |
|---|---|
static AssetImpl |
createAssetFromData(byte[] data,
@NonNull String logicalPath,
boolean overwrite,
@NonNull Optional<Map<String,Object>> metadata,
@NonNull Optional<String> type)
Creates the
Asset from the file-like data. |
static AssetImpl |
createAssetFromFile(@NonNull File file,
Optional<String> logicalPath,
boolean overwrite,
@NonNull Optional<Map<String,Object>> metadata,
@NonNull Optional<String> type)
Creates the
Asset from the local file. |
static RemoteAssetImpl |
createRemoteAsset(@NonNull URI uri,
Optional<String> logicalPath,
boolean overwrite,
Optional<Map<String,Object>> metadata,
Optional<String> type)
Creates remote asset representation encapsulated into
RemoteAsset instance. |
static AssetType |
toAssetType(@NonNull String typeName)
Allows converting type name to the
AssetType. |
static AssetImpl |
updateAsset(AssetImpl asset,
boolean overwrite,
Optional<Map<String,Object>> metadata,
Optional<String> type)
Updates provided
AssetImpl with values from optionals or with defaults. |
static Stream<AssetImpl> |
walkFolderAssets(@NonNull File folder,
boolean logFilePath,
boolean recursive,
boolean prefixWithFolderName,
@NonNull Optional<Map<String,Object>> metadata,
@NonNull Optional<String> type,
@NonNull Optional<String> groupingName)
Walks through the asset files in the given folder and produce stream of
Asset objects holding information
about file assets found in the folder. |
public static final String REMOTE_FILE_NAME_DEFAULT
public static Stream<AssetImpl> walkFolderAssets(@NonNull @NonNull File folder, boolean logFilePath, boolean recursive, boolean prefixWithFolderName, @NonNull @NonNull Optional<Map<String,Object>> metadata, @NonNull @NonNull Optional<String> type, @NonNull @NonNull Optional<String> groupingName) throws IOException
Asset objects holding information
about file assets found in the folder.folder - the folder where to look for asset fileslogFilePath - if true the file path relative to the folder will be used.
Otherwise, basename of the asset file will be used.recursive - if true then subfolder files will be included recursively.prefixWithFolderName - if true then path of each asset file will be prefixed with folder name
in case if logFilePath is true.metadata - the optional metadata to associate with assets.type - optional type of the asset (default: ASSET).groupingName - optional name of group the assets should belong.AssetImpl objects.IOException - if an I/O exception occurred.public static RemoteAssetImpl createRemoteAsset(@NonNull @NonNull URI uri, Optional<String> logicalPath, boolean overwrite, Optional<Map<String,Object>> metadata, Optional<String> type)
RemoteAsset instance.uri - the URI pointing to the remote asset location. There is no imposed format,
and it could be a private link.logicalPath - the optional "name" of the remote asset, could be a dataset name, a model file name.overwrite - if true will overwrite all existing assets with the same name.metadata - Some additional data to attach to the remote asset.
The dictionary values must be JSON compatible.type - the type of the asset. If not specified the default type AssetType.ASSET
will be assigned.RemoteAssetImpl instance.public static AssetImpl createAssetFromFile(@NonNull @NonNull File file, Optional<String> logicalPath, boolean overwrite, @NonNull @NonNull Optional<Map<String,Object>> metadata, @NonNull @NonNull Optional<String> type)
Asset from the local file.file - the asset file.logicalPath - the logical name for the asset file.overwrite - if true mark as overridemetadata - the metadata to associate with asset. The dictionary values must be JSON compatible.type - the type of the asset. If not specified the default type AssetType.ASSET
will be assigned.AssetImpl from the local file.public static AssetImpl createAssetFromData(byte[] data, @NonNull @NonNull String logicalPath, boolean overwrite, @NonNull @NonNull Optional<Map<String,Object>> metadata, @NonNull @NonNull Optional<String> type)
Asset from the file-like data.data - the asset's data.logicalPath - the logical name for the asset file.overwrite - if true mark as overridemetadata - the metadata to associate with asset. The dictionary values must be JSON compatible.type - the type of the asset. If not specified the default type AssetType.ASSET_TYPE_ASSET
will be assigned.AssetImpl from the file-like data.public static AssetImpl updateAsset(AssetImpl asset, boolean overwrite, Optional<Map<String,Object>> metadata, Optional<String> type)
AssetImpl with values from optionals or with defaults.asset - the AssetImpl to be updated.overwrite - if true will overwrite all existing assets with the same name.metadata - Some additional data to attach to the remote asset.
The dictionary values must be JSON compatible.type - the type of the asset. If not specified the default type AssetType.ASSET_TYPE_ASSET
will be assigned.AssetImpl with values from optionals or with defaults.Copyright © 2022. All rights reserved.