The JVM SDK currently only supports legacy versions of Nitric prior to v1. This version is maintained for compatibility with existing projects and not recommended for new projects. New projects should be started using a supported SDK (presented automatically using the `nitric new` command) orget in touch to request an update to the latest version.
JVM - bucket.files()
Get a list of file references for files that exist in the bucket.
import io.nitric.Nitric;
import io.nitric.resources.BucketPermission;
public class Application {
public static void main(String[] args) {
var bucket = Nitric.INSTANCE.bucket("images").with(BucketPermission.Read);
var files = bucket.files();
Nitric.INSTANCE.run();
}
}
Examples
Deleting all files in a bucket.
import io.nitric.Nitric;
import io.nitric.resources.BucketPermission;
public class Application {
public static void main(String[] args) {
var bucket = Nitric.INSTANCE.bucket("bucket").with(BucketPermission.Read);
var files = bucket.files();
files.forEach((file) -> file.delete());
Nitric.INSTANCE.run();
}
}
Notes
This method returns a list of File references that exist on the bucket.