This is the mito-attachment Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 06:08:38 2024 GMT+0.
mito-attachment/mito-attachment.asd
mito-attachment/src/mito-attachment.lisp
mito-attachment/src/mixin.lisp
mito-attachment/src/storage.lisp
mito-attachment/src/storage-components/disk.lisp
mito-attachment/src/storage-components/s3.lisp
mito-attachment/src/util.lisp
The main system appears first, followed by any subsystem dependency.
mito-attachment
Mito mixin class for file management
Eitaro Fukamachi
LLGPL
# mito-attachment
The place to store files would be a problem when you intend to write a web application which allows file-uploading. These days, AWS S3 is a common place to store/serve files, however, it’s not easy to manage like RDBMS.
Mito-attachment provides a Mito mixin class for managing files outside of RDBMS. It stores files before ‘mito:save-dao‘ and deletes them before ‘mito:delete-dao‘.
Besides, the backend storage can be replaced easily. This makes it easy that using cloud storage services for production environment and using local filesystem for development environment.
## Usage
### Setting up the storage
“‘common-lisp
(defvar *appenv* (uiop:getenv "APP_ENV"))
;; Setup storage class
(setf *storage*
(if (string= *appenv* "production")
;; Store files in AWS S3 for production environment
(make-instance ’s3-storage
:bucket "mito-attachment-example"
:endpoint "s3-ap-northeast-1.amazonaws.com"
:access-key (uiop:getenv "AWS_ACCESS_KEY")
:secret-key (uiop:getenv "AWS_SECRET_KEY"))
;; Store files in local filesystem for development environment
(make-instance ’disk-storage
:bucket "mito-attachment-example"
:directory #P"/tmp/attachment/")))
“‘
### Defining an attachment Mito class
“‘common-lisp
;; Attachment class for saving metadata into RDBMS
(defclass image (attachment) ()
(:metaclass mito:dao-table-class))
“‘
### Saving
“‘common-lisp
;; :content can be specified as a pathname or a stream.
(mito:create-dao ’image :content #P"uploaded-file.png")
;; Override the file content-type
(mito:create-dao ’image :content #P"uploaded-file.png" :content-type "image/png")
;; Use an original file-key
(mito:create-dao ’image :content #P"uploaded-file.png" :file-key "image.png")
“‘
### Getting the URL
“‘common-lisp
(let ((file (mito:find-dao ’image :id 1)))
(file-url file))
;-> ;; SELECT * FROM "image" WHERE ("id" = ?) LIMIT 1 (1) [1 row] | MITO.DB:RETRIEVE-BY-SQL
;=> "/mito-attachment-example/3616D80112884799B272DC962F4BBF97.jpg"
“‘
Additionally, ‘file-signed-url‘ can also be used for getting a signed URL (ex. Amazon S3 Presigned URL).
See [example.lisp](example.lisp) for getting the full example. It’s a Lack web application which allows users to upload image files.
## Installation
“‘common-lisp
(ql:quickload :mito-attachment)
“‘
## See Also
* [Mito](https://github.com/fukamachi/mito)
* [Clipper](https://github.com/Rudolph-Miller/clipper) for Integral
## Author
* Eitaro Fukamachi (e.arrows@gmail.com)
## Copyright
Copyright (c) 2016 Eitaro Fukamachi (e.arrows@gmail.com)
## License
Licensed under the LLGPL License.
0.1
mito
(system).
zs3
(system).
aws-sign4
(system).
lack-component
(system).
trivial-mimes
(system).
quri
(system).
uuid
(system).
uiop
(system).
alexandria
(system).
src
(module).
Modules are listed depth-first from the system components tree.
mito-attachment/src
mito-attachment
(system).
mito-attachment.lisp
(file).
mixin.lisp
(file).
storage.lisp
(file).
storage-components
(module).
util.lisp
(file).
mito-attachment/src/storage-components
storage.lisp
(file).
util.lisp
(file).
src
(module).
Files are sorted by type and then listed depth-first from the systems components trees.
mito-attachment/mito-attachment.asd
mito-attachment/src/mito-attachment.lisp
mito-attachment/src/mixin.lisp
mito-attachment/src/storage.lisp
mito-attachment/src/storage-components/disk.lisp
mito-attachment/src/storage-components/s3.lisp
mito-attachment/src/util.lisp
mito-attachment/mito-attachment.asd
mito-attachment
(system).
mito-attachment/src/mito-attachment.lisp
mixin.lisp
(file).
storage.lisp
(file).
storage-components
(module).
src
(module).
mito-attachment/src/mixin.lisp
storage.lisp
(file).
util.lisp
(file).
src
(module).
attachment
(class).
content
(reader method).
(setf content)
(writer method).
(setf content)
(method).
content-type
(reader method).
(setf content-type)
(writer method).
delete-dao
(method).
file-key
(reader method).
(setf file-key)
(writer method).
file-signed-url
(generic function).
file-size
(reader method).
(setf file-size)
(writer method).
file-url
(generic function).
get-object
(generic function).
initialize-instance
(method).
save-dao
(method).
initialize-with-content
(function).
mito-attachment/src/storage.lisp
src
(module).
*storage*
(special variable).
delete-object-from-storage
(generic function).
get-object-in-storage
(generic function).
storage
(class).
storage-bucket
(reader method).
(setf storage-bucket)
(writer method).
storage-endpoint
(reader method).
(setf storage-endpoint)
(writer method).
storage-file-signed-url
(generic function).
storage-file-url
(generic function).
storage-prefix
(reader method).
(setf storage-prefix)
(writer method).
store-object-in-storage
(generic function).
mito-attachment/src/storage-components/disk.lisp
storage-components
(module).
call
(method).
delete-object-from-storage
(method).
disk-storage
(class).
disk-storage-bucket-directory
(generic function).
disk-storage-directory
(reader method).
(setf disk-storage-directory)
(writer method).
disk-storage-file
(generic function).
disk-storage-mount-path
(generic function).
get-object-in-storage
(method).
storage-file-url
(method).
store-object-in-storage
(method).
store-object-in-storage
(method).
store-object-in-storage
(method).
disk-storage-mount-path-prefix
(reader method).
(setf disk-storage-mount-path-prefix)
(writer method).
mito-attachment/src/storage-components/s3.lisp
storage-components
(module).
delete-object-from-storage
(method).
get-object-in-storage
(method).
s3-storage
(class).
s3-storage-credentials
(generic function).
storage-file-signed-url
(method).
storage-file-url
(method).
store-object-in-storage
(method).
store-object-in-storage
(method).
store-object-in-storage
(method).
s3-file-key
(function).
s3-storage-region
(reader method).
(setf s3-storage-region)
(writer method).
with-s3-storage
(macro).
mito-attachment/src/util.lisp
src
(module).
slurp-stream
(function).
Packages are listed by definition order.
mito-attachment
mito.attachment.mixin
mito.attachment.storage.s3
mito.attachment.storage.disk
mito-attachment.util
mito-attachment-asd
mito.attachment.storage
mito.attachment.mixin
common-lisp
.
attachment
(class).
content
(generic reader).
(setf content)
(generic function).
content-type
(generic reader).
(setf content-type)
(generic writer).
file-key
(generic reader).
(setf file-key)
(generic writer).
file-signed-url
(generic function).
file-size
(generic reader).
(setf file-size)
(generic writer).
file-url
(generic function).
get-object
(generic function).
initialize-with-content
(function).
mito.attachment.storage.s3
common-lisp
.
mito.attachment.storage
.
s3-storage
(class).
s3-storage-credentials
(generic function).
s3-file-key
(function).
s3-storage-region
(generic reader).
(setf s3-storage-region)
(generic writer).
with-s3-storage
(macro).
mito.attachment.storage.disk
common-lisp
.
mito.attachment.storage
.
disk-storage
(class).
disk-storage-bucket-directory
(generic function).
disk-storage-directory
(generic reader).
(setf disk-storage-directory)
(generic writer).
disk-storage-file
(generic function).
disk-storage-mount-path
(generic function).
disk-storage-mount-path-prefix
(generic reader).
(setf disk-storage-mount-path-prefix)
(generic writer).
mito.attachment.storage
common-lisp
.
*storage*
(special variable).
delete-object-from-storage
(generic function).
get-object-in-storage
(generic function).
storage
(class).
storage-bucket
(generic reader).
(setf storage-bucket)
(generic writer).
storage-endpoint
(generic reader).
(setf storage-endpoint)
(generic writer).
storage-file-signed-url
(generic function).
storage-file-url
(generic function).
storage-prefix
(generic reader).
(setf storage-prefix)
(generic writer).
store-object-in-storage
(generic function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
attachment
)) ¶automatically generated reader method
attachment
)) ¶attachment
)) ¶automatically generated writer method
attachment
)) ¶automatically generated reader method
attachment
)) ¶automatically generated writer method
s3-storage
) file-key) ¶disk-storage
) file-key) ¶disk-storage
)) ¶disk-storage
)) ¶automatically generated reader method
disk-storage
)) ¶automatically generated writer method
disk-storage
) file-key) ¶disk-storage
)) ¶attachment
)) ¶automatically generated reader method
attachment
)) ¶automatically generated writer method
attachment
) &rest args &key method expires-in) ¶attachment
)) ¶automatically generated reader method
attachment
)) ¶automatically generated writer method
attachment
)) ¶attachment
)) ¶s3-storage
) file-key) ¶disk-storage
) file-key) ¶s3-storage
)) ¶s3-storage
) file-key &key method expires-in) ¶s3-storage
) file-key) ¶disk-storage
) file-key) ¶s3-storage
) (object sequence
) file-key) ¶s3-storage
) (object stream
) file-key) ¶s3-storage
) (object pathname
) file-key) ¶disk-storage
) (object sequence
) file-key) ¶disk-storage
) (object stream
) file-key) ¶disk-storage
) (object pathname
) file-key) ¶disk-storage
) env) ¶lack.component
.
attachment
)) ¶mito.dao
.
attachment
) &rest initargs &key content &allow-other-keys) ¶attachment
)) ¶mito.dao
.
lack-component
.
storage
.
call
.
delete-object-from-storage
.
disk-storage-bucket-directory
.
(setf disk-storage-directory)
.
disk-storage-directory
.
disk-storage-file
.
disk-storage-mount-path
.
(setf disk-storage-mount-path-prefix)
.
disk-storage-mount-path-prefix
.
get-object-in-storage
.
storage-file-url
.
store-object-in-storage
.
store-object-in-storage
.
store-object-in-storage
.
common-lisp
.
:directory
:mount-path-prefix
Initarg | Value |
---|---|
:endpoint | *s3-endpoint* |
:access-key
:secret-key
:session-token
zs3:*s3-region*
:region
disk-storage
)) ¶automatically generated reader method
disk-storage
)) ¶automatically generated writer method
s3-storage
)) ¶automatically generated reader method
s3-storage
)) ¶automatically generated writer method
Jump to: | (
C D F G I M S W |
---|
Jump to: | (
C D F G I M S W |
---|
Jump to: | *
A B C D E F M P R S |
---|
Jump to: | *
A B C D E F M P R S |
---|
Jump to: | A C D F M P S U |
---|
Jump to: | A C D F M P S U |
---|