Class BlossomEndpoint
java.lang.Object
org.ngengine.blossom4j.BlossomEndpoint
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.ngengine.platform.AsyncTask<BlossomResponse> delete(String sha256, SignedNostrEvent authEvent) Delete a blob by its SHA256 hashbooleanorg.ngengine.platform.AsyncTask<Boolean> exists(String sha256OrPath, SignedNostrEvent authEvent) Check if a blob existsorg.ngengine.platform.AsyncTask<BlossomBlobResponse> get(String sha256OrPath, int[] byteRange, SignedNostrEvent authEvent) Get blob by SHA256getUrl()inthashCode()org.ngengine.platform.AsyncTask<org.ngengine.platform.transport.NGEHttpResponse> httpRequest(String endpoint, String method, Map<String, String> headers, byte[] body, SignedNostrEvent authEvent) org.ngengine.platform.AsyncTask<org.ngengine.platform.transport.NGEHttpResponse> httpRequest(String endpoint, String method, Map<String, String> headers, ByteBuffer body, SignedNostrEvent authEvent) org.ngengine.platform.AsyncTask<org.ngengine.platform.transport.NGEHttpResponse> httpRequest(String endpoint, String method, Map<String, String> headers, SignedNostrEvent authEvent) booleanorg.ngengine.platform.AsyncTask<BlossomResponse> list(NostrPublicKey pubkey, Instant since, Instant until, SignedNostrEvent authEvent) List blobs uploaded by a given public keyorg.ngengine.platform.AsyncTask<BlossomResponse> media(byte[] data, String mimeType, SignedNostrEvent authEvent) BUD-05: unlike /upload, the returned hash may differ from the submitted bytes.org.ngengine.platform.AsyncTask<BlossomResponse> mirror(String source, SignedNostrEvent authEvent) BUD-04: the server, never the client, downloads the source URL.voidsetVerifyBlobs(boolean verify) org.ngengine.platform.AsyncTask<Boolean> Checks an endpoint with an unauthenticated OPTIONS request and caches either result.toString()org.ngengine.platform.AsyncTask<BlossomResponse> upload(byte[] data, String mimeType, SignedNostrEvent authEvent) Upload a bloborg.ngengine.platform.AsyncTask<BlossomResponse> upload(ByteBuffer data, String mimeType, SignedNostrEvent authEvent) voidvalidateDescriptor(BlobDescriptor descriptor) Only this explicitly configured server may supply the resulting URL.
-
Constructor Details
-
BlossomEndpoint
-
-
Method Details
-
getUrl
-
supports
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
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.extbyteRange- optional, the range of bytes to fetch, can be null for full rangeauthEvent- 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.extauthEvent- 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 uploadmimeType- (optional), the MIME type of the blob, can be null for application/octet-streamauthEvent- (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 listsince- (optional) the start time for the listing, can be nulluntil- (optional) the end time for the listing, can be nullauthEvent- (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
-
equals
-
hashCode
-
httpRequest
-
httpRequest
-
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)
-