Class ImageStore
java.lang.Object
dev.despical.pixelpainter.image.ImageStore
Owns local PNG, JPEG and WebP files and bounded downloads from trusted HTTPS hosts.
Names use a flat namespace. Resolution excludes symbolic links and requires an explicit extension when a base name is ambiguous. Decode checks byte size, format and source dimensions before reading pixels.
Downloads validate redirect destinations, reject local addresses, enforce byte and read-time limits, and decode a temporary file before promoting it. Existing files are never replaced. These blocking operations belong on image workers and do not access Bukkit worlds. Trust the configured host owners.
-
Constructor Summary
ConstructorsConstructorDescriptionImageStore(Path folder) Creates the source directory and resolves its real filesystem location. -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageValidates byte size, format and source dimensions before reading pixels.voidDeletes a resolved source without changing paintings or undo journals.Downloads and validates an image before moving it into the source directory.list()Lists valid, regular source files without following symbolic links.Resolves and decodes a source image using captured limits.Resolves a case-insensitive name or an unambiguous extensionless base name.static StringValidates a flat source name with an optional PNG, JPEG or WebP extension.
-
Constructor Details
-
ImageStore
Creates the source directory and resolves its real filesystem location.- Parameters:
folder- source-image directory- Throws:
IOException- if the directory cannot be created or resolved
-
-
Method Details
-
validName
Validates a flat source name with an optional PNG, JPEG or WebP extension.- Parameters:
input- letters, digits, underscores or hyphens with an optional extension- Returns:
- unchanged input
- Throws:
IllegalArgumentException- if the name violates the filename policy
-
list
Lists valid, regular source files without following symbolic links.- Returns:
- source names sorted without regard to case
- Throws:
IOException- if directory scanning fails
-
resolve
Resolves a case-insensitive name or an unambiguous extensionless base name.- Parameters:
name- validated source name- Returns:
- path of the existing source image
- Throws:
IOException- if scanning failsIllegalArgumentException- if the name is invalid, missing or ambiguous
-
read
Resolves and decodes a source image using captured limits.- Parameters:
name- source namesettings- request settings- Returns:
- decoded image
- Throws:
IOException- if the file cannot be readIllegalArgumentException- if name, format or size validation fails
-
decode
Validates byte size, format and source dimensions before reading pixels.- Parameters:
file- existing image filesettings- source limits- Returns:
- decoded first image
- Throws:
IOException- if metadata or content cannot be readIllegalArgumentException- if format, bytes or dimensions are unsupported
-
delete
Deletes a resolved source without changing paintings or undo journals.- Parameters:
name- source name- Throws:
IOException- if deletion or resolution failsIllegalArgumentException- if the name is invalid, missing or ambiguous
-
download
Downloads and validates an image before moving it into the source directory.- Parameters:
name- destination name; an absent extension becomes .pnglink- trusted HTTPS source URLsettings- captured download hosts and limits- Returns:
- saved destination filename
- Throws:
Exception- if network access, validation, decoding or promotion fails
-