Liking cljdoc? Tell your friends :D

wagoe.storage.ports

Port definitions for file storage functionality.

This namespace defines the contracts that storage adapters must implement. Follows the Functional Core / Imperative Shell pattern where ports define the boundaries between pure logic and side effects.

Port definitions for file storage functionality.

This namespace defines the contracts that storage adapters must implement.
Follows the Functional Core / Imperative Shell pattern where ports define
the boundaries between pure logic and side effects.
raw docstring

IExportJobStorecljprotocol

Data exports produced by a background job. A job is {:id :subject :requested-by :status :file-key :error :created-at :finished-at :expires-at}, :subject {:type :user|:tenant :id}, :status :pending, :running, :done or :failed.

Data exports produced by a background job. A job is {:id :subject
:requested-by :status :file-key :error :created-at :finished-at :expires-at},
`:subject` {:type :user|:tenant :id}, `:status` :pending, :running, :done or
:failed.

count-export-jobs-requested-sinceclj

(count-export-jobs-requested-since this requested-by since)

How many jobs requested-by asked for since since, an Instant.

How many jobs `requested-by` asked for since `since`, an Instant.

create-export-job!clj

(create-export-job! this job)

Store job, a new :pending one, and return it; nil when its requester has a :pending or :running job for its subject already.

Store `job`, a new :pending one, and return it; nil when its requester
has a :pending or :running job for its subject already.

export-jobs-created-beforeclj

(export-jobs-created-before this cutoff open-before limit)

At most limit jobs created before cutoff, an Instant, oldest first. A :pending or :running job only when also created before open-before: a worker may still be building it.

At most `limit` jobs created before `cutoff`, an Instant, oldest first.
A :pending or :running job only when also created before `open-before`:
a worker may still be building it.

find-export-jobclj

(find-export-job this id)

The job with id, or nil.

The job with `id`, or nil.

open-export-jobclj

(open-export-job this subject requested-by)

requested-by's :pending or :running job for subject, or nil.

`requested-by`'s :pending or :running job for `subject`, or nil.

remove-export-job!clj

(remove-export-job! this id)

Forget the job with id.

Forget the job with `id`.

save-export-job!clj

(save-export-job! this job)

Store job, replacing the one with its id. Returns it.

Store `job`, replacing the one with its id. Returns it.
sourceraw docstring

IFileStoragecljprotocol

Port for file storage operations.

Implementations can store files locally, in S3, GCS, or other storage backends. All operations should be idempotent where possible.

Port for file storage operations.

Implementations can store files locally, in S3, GCS, or other storage backends.
All operations should be idempotent where possible.

delete-fileclj

(delete-file this file-key)

Delete a file from storage.

Parameters:

  • file-key: Unique identifier for the stored file

Returns: Boolean indicating success

Delete a file from storage.

Parameters:
- file-key: Unique identifier for the stored file

Returns:
Boolean indicating success

file-exists?clj

(file-exists? this file-key)

Check if a file exists in storage.

Parameters:

  • file-key: Unique identifier for the stored file

Returns: Boolean indicating existence. Throws when it cannot tell: a caller that deletes a record for a file that is gone must not read an outage as gone.

Check if a file exists in storage.

Parameters:
- file-key: Unique identifier for the stored file

Returns:
Boolean indicating existence. Throws when it cannot tell: a caller that
deletes a record for a file that is gone must not read an outage as gone.

generate-signed-urlclj

(generate-signed-url this file-key expiration-seconds)

Generate a time-limited signed URL for secure file access.

Parameters:

  • file-key: Unique identifier for the stored file
  • expiration-seconds: How long the URL should be valid

Returns: String containing the signed URL, or nil if not supported

Generate a time-limited signed URL for secure file access.

Parameters:
- file-key: Unique identifier for the stored file
- expiration-seconds: How long the URL should be valid

Returns:
String containing the signed URL, or nil if not supported

retrieve-fileclj

(retrieve-file this file-key)

Retrieve a file by its storage key.

Parameters:

  • file-key: Unique identifier for the stored file

Returns: Map with :bytes, :content-type, :size, or nil if not found

Retrieve a file by its storage key.

Parameters:
- file-key: Unique identifier for the stored file

Returns:
Map with :bytes, :content-type, :size, or nil if not found

store-fileclj

(store-file this file-data metadata)

Store a file and return storage metadata.

Parameters:

  • file-data: Map containing :bytes (byte array) and :content-type
  • metadata: Map with :filename, :path (optional), :visibility (public/private)

Returns: Map with :key (storage identifier), :url (access URL), :size, :content-type

Store a file and return storage metadata.

Parameters:
- file-data: Map containing :bytes (byte array) and :content-type
- metadata: Map with :filename, :path (optional), :visibility (public/private)

Returns:
Map with :key (storage identifier), :url (access URL), :size, :content-type
sourceraw docstring

IImageProcessorcljprotocol

Port for image processing operations.

Implementations can use different image processing libraries (ImageMagick, Java AWT, etc.) to manipulate images.

Port for image processing operations.

Implementations can use different image processing libraries (ImageMagick,
Java AWT, etc.) to manipulate images.

create-thumbnailclj

(create-thumbnail this image-bytes size)

Create a thumbnail from an image.

Parameters:

  • image-bytes: Byte array of the original image
  • size: Integer for max dimension (will maintain aspect ratio)

Returns: Byte array of the thumbnail

Create a thumbnail from an image.

Parameters:
- image-bytes: Byte array of the original image
- size: Integer for max dimension (will maintain aspect ratio)

Returns:
Byte array of the thumbnail

get-image-infoclj

(get-image-info this image-bytes)

Get metadata about an image.

Parameters:

  • image-bytes: Byte array of the image

Returns: Map with :width, :height, :format, :size

Get metadata about an image.

Parameters:
- image-bytes: Byte array of the image

Returns:
Map with :width, :height, :format, :size

is-image?clj

(is-image? this bytes content-type)

Check if the provided bytes represent a valid image.

Parameters:

  • bytes: Byte array to check
  • content-type: MIME type (optional hint)

Returns: Boolean indicating if this is a valid image

Check if the provided bytes represent a valid image.

Parameters:
- bytes: Byte array to check
- content-type: MIME type (optional hint)

Returns:
Boolean indicating if this is a valid image

resize-imageclj

(resize-image this image-bytes dimensions)

Resize an image to specified dimensions.

Parameters:

  • image-bytes: Byte array of the original image
  • dimensions: Map with :width and :height (either can be nil for proportional)

Returns: Byte array of the resized image

Resize an image to specified dimensions.

Parameters:
- image-bytes: Byte array of the original image
- dimensions: Map with :width and :height (either can be nil for proportional)

Returns:
Byte array of the resized image
sourceraw docstring

IStreamingFileStoragecljprotocol

Optional, beside IFileStorage, for an adapter that can store a file without holding all of it in memory.

Optional, beside `IFileStorage`, for an adapter that can store a file
without holding all of it in memory.

store-streamclj

(store-stream this file-data metadata)

Store what (write! out) writes to an OutputStream. file-data is {:write! fn :content-type}; metadata and the result are store-file's. When write! throws, nothing is stored and its exception propagates.

Store what `(write! out)` writes to an OutputStream. `file-data` is
{:write! fn :content-type}; `metadata` and the result are `store-file`'s.
When `write!` throws, nothing is stored and its exception propagates.
sourceraw docstring

IUploadIndexcljprotocol

Who stored which file, and when. IFileStorage cannot list files, so data export and upload retention read this instead.

An upload is {:key :user-id :tenant-id :size :content-type :stored-at}; either owner may be nil.

Who stored which file, and when. `IFileStorage` cannot list files, so data
export and upload retention read this instead.

An upload is {:key :user-id :tenant-id :size :content-type :stored-at};
either owner may be nil.

find-uploadsclj

(find-uploads this owner opts)

Uploads of owner, {:user-id id} or {:tenant-id id}, in key order. opts: :limit, and :after-key to read the page after that key.

Uploads of `owner`, {:user-id id} or {:tenant-id id}, in key order.
`opts`: :limit, and :after-key to read the page after that key.

record-upload!clj

(record-upload! this upload)

Record upload, replacing any record with the same key.

Record `upload`, replacing any record with the same key.

remove-upload!clj

(remove-upload! this file-key)

Forget the upload at file-key. Returns true when there was one.

Forget the upload at `file-key`. Returns true when there was one.

uploads-stored-beforeclj

(uploads-stored-before this cutoff limit)

At most limit uploads stored before cutoff, an Instant.

At most `limit` uploads stored before `cutoff`, an Instant.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close