Class Bucket


  • public class Bucket
    extends Object

    Provides a Storage API bucket class.

    The example below illustrates the Storage API.

    
      import io.nitric.api.storage.Storage;
      ...
    
      byte[] imageData = ...
    
      // Store a file: 'inspection-images/582764-front-elevation.jpg'
      Storage.bucket("inspection-images")
         .file("582764-front-elevation.jpg")
         .write(imageData);
    
      // Load an image file
      imageData = Storage.bucket("inspection-images")
          .file("582764-side-elevation.jpg")
          .read();
    
      // Delete an image file
      Storage.bucket(bucket)
          .file("582764-rear-elevation.jpg")
          .delete();
     
    • Method Detail

      • getName

        public String getName()
        Return the bucket name.
        Returns:
        the bucket name
      • file

        public File file​(String key)
        Create a storage file object with the given key.
        Parameters:
        key - the storage file key (required)
        Returns:
        a new storage file object
      • toString

        public String toString()
        Return the string representation of this object.
        Overrides:
        toString in class Object
        Returns:
        the string representation of this object