Class BlossomEndpoint

java.lang.Object
org.ngengine.blossom4j.BlossomEndpoint

public class BlossomEndpoint extends Object
  • Constructor Details

    • BlossomEndpoint

      public BlossomEndpoint(String url)
  • Method Details

    • getUrl

      public String getUrl()
    • supports

      public org.ngengine.platform.AsyncTask<Boolean> supports(String operation)
      Checks an endpoint with an unauthenticated OPTIONS request and caches either result. Authorization requirements still indicate an available endpoint. Transport failures, rate limits and temporary server errors fail the task without caching a negative result. Actual operation responses update the cache if a server changes or uses generic preflight handling.
      Parameters:
      operation - endpoint name, such as mirror or media
      Returns:
      whether the endpoint is available according to the probe or a previous operation
    • mirror

      public org.ngengine.platform.AsyncTask<BlossomResponse> mirror(String source, @Nullable SignedNostrEvent authEvent)
      BUD-04: the server, never the client, downloads the source URL.
    • media

      public org.ngengine.platform.AsyncTask<BlossomResponse> media(byte[] data, @Nullable String mimeType, @Nullable SignedNostrEvent authEvent)
      BUD-05: unlike /upload, the returned hash may differ from the submitted bytes.
    • validateDescriptor

      public void validateDescriptor(BlobDescriptor descriptor) throws IOException
      Only this explicitly configured server may supply the resulting URL.
      Throws:
      IOException
    • setVerifyBlobs

      public void setVerifyBlobs(boolean verify)
    • isVerifyBlobs

      public boolean isVerifyBlobs()
    • get

      public org.ngengine.platform.AsyncTask<BlossomBlobResponse> get(String sha256OrPath, int[] byteRange, @Nullable SignedNostrEvent authEvent)
      Get blob by SHA256
      Parameters:
      sha256OrPath - can be just sha256 or sha256.ext
      byteRange - optional, the range of bytes to fetch, can be null for full range
      authEvent - optional, can be null
      Returns:
    • exists

      public org.ngengine.platform.AsyncTask<Boolean> exists(String sha256OrPath, @Nullable SignedNostrEvent authEvent)
      Check if a blob exists
      Parameters:
      sha256OrPath - can be just sha256 or sha256.ext
      authEvent - optional, can be null
      Returns:
      an AsyncTask that returns true if the blob exists, false if it does not
    • upload

      public org.ngengine.platform.AsyncTask<BlossomResponse> upload(byte[] data, @Nullable String mimeType, @Nullable SignedNostrEvent authEvent)
      Upload a blob
      Parameters:
      data - the byte array to upload
      mimeType - (optional), the MIME type of the blob, can be null for application/octet-stream
      authEvent - (optional), a SignedNostrEvent for authorization, can be null
      Returns:
      an AsyncTask that returns a BlossomResponse containing the BlobDescriptor and the HTTP response
    • upload

      public org.ngengine.platform.AsyncTask<BlossomResponse> upload(ByteBuffer data, @Nullable String mimeType, @Nullable SignedNostrEvent authEvent)
    • list

      public org.ngengine.platform.AsyncTask<BlossomResponse> list(NostrPublicKey pubkey, @Nullable Instant since, @Nullable Instant until, @Nullable SignedNostrEvent authEvent)
      List blobs uploaded by a given public key
      Parameters:
      pubkey - the public key of the user whose blobs you want to list
      since - (optional) the start time for the listing, can be null
      until - (optional) the end time for the listing, can be null
      authEvent - (optional) a SignedNostrEvent for authorization, can be null
      Returns:
      an AsyncTask that returns a BlossomResponse containing a list of BlobDescriptors and the HTTP response
    • delete

      public org.ngengine.platform.AsyncTask<BlossomResponse> delete(String sha256, @Nullable SignedNostrEvent authEvent)
      Delete a blob by its SHA256 hash
      Parameters:
      sha256 -
      authEvent -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • httpRequest

      public org.ngengine.platform.AsyncTask<org.ngengine.platform.transport.NGEHttpResponse> httpRequest(String endpoint, String method, @Nullable Map<String,String> headers, @Nullable SignedNostrEvent authEvent)
    • httpRequest

      public org.ngengine.platform.AsyncTask<org.ngengine.platform.transport.NGEHttpResponse> httpRequest(String endpoint, String method, @Nullable Map<String,String> headers, @Nullable byte[] body, @Nullable SignedNostrEvent authEvent)
    • httpRequest

      public org.ngengine.platform.AsyncTask<org.ngengine.platform.transport.NGEHttpResponse> httpRequest(String endpoint, String method, @Nullable Map<String,String> headers, ByteBuffer body, @Nullable SignedNostrEvent authEvent)