Catalyst::Controller::SimpleCAS - General-purpose content-addressed storage (CAS) for Catalyst
use Catalyst::Controller::SimpleCAS; ...
This controller provides a simple content-addressed storage backend for Catalyst applications.
This module was originally developed within RapidApp before being extracted into its own module. This is a preliminary version which matches what was in RapidApp (and is still rough around the edges, poor test coverage, incomplete docs, etc). Subsequent versions will be polished better, as well as have API changes and improvements...
Other than for RapidApp itself, it is not suggested that this module be used yet in production...
Object class to use for the Store backend. Defaults to Catalyst::Controller::SimpleCAS::Store::File
Catalyst::Controller::SimpleCAS::Store::File
Directory/path to be used by the Store. Defaults to cas_store within the Catalyst home directory.
cas_store
Actual object instance of the Store. By default this object is built using the store_class (by calling new()) with the store_path supplied to the constructor.
store_class
new()
store_path
Name of an optional Catalyst View to forward to to render JSON responses, with the pre-encoded JSON set in the stash key 'jsonData'. If not set, the encoded JSON is simply set in response body with the Content-Type set to application/json.
application/json
If the view name RapidApp::View is loaded (which is the case when RapidApp is loaded), it is used as the default. This is needed to support special round-trip encodings for "Insert Image" and other ExtJS-based upload interfaces.
RapidApp::View
Upload new content to the CAS and return the sha1 checksum in the body to be able to access it later. Because of the CAS design, the system automatically deduplicates, and will only ever store a single copy of a given unique piece of content in the Store.
Fetch existing content from the CAS according its sha1 checksum.
Example:
GET /simplecas/fetch_content/fdb379f7e9c8d0a1fcd3b5ee4233d88c5a4a023e
The system attempts to identify the content type and sets the MIME type accordingly. Additionally, an optional filename argument can be also be supplied in the URL
GET /simplecas/fetch_content/fdb379f7e9c8d0a1fcd3b5ee4233d88c5a4a023e/somefile.txt
The main reason this is supported is simply for more human-friendly URLs. The name is not stored or validated in any way. If supplied, this does nothing other than being used to set the content-disposition:
Content-Disposition: attachment; filename="somefile.txt"
When there is no filename second arg supplied, the content-disposition is set like this:
Content-Disposition: inline;filename="fdb379f7e9c8d0a1fcd3b5ee4233d88c5a4a023e"
Works like upload_content, but returns a JSON packet with additional metadata/information in the body.
upload_content
Works like upload_file, but with some image-specific functionality, including client-supplied max width and height values supplied as the first and second args, respectively. For example, a POST upload with Filedata containing an image, and declared max size of 800x600 uses a URL like:
upload_file
POST /simplecas/upload_image/800/600
When the image is larger than the max width or height, if the optional dependency Image::Resize is available (which requires GD) it is used to resize the image, preserving height/width proportions accordingly, and the new, resized image is what is stored in the CAS. Otherwise, the image is not resized, but resized dimensions are returned in the JSON packet so the client can generate an img tag for display.
img
Originally, Image::Resize was a standard dependency, but this can be a PITA to get installed with all of the dependencies of GD.
This does nothing but accept a standard POST/Filedata upload and return it as base64 in a JSON packet within the JSON/object key echo_content.
echo_content
Not usually called directly
Catalyst
Catalyst::Controller
RapidApp
Henry Van Styn <vanstyn@cpan.org>
This software is copyright (c) 2014 by IntelliTree Solutions llc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Catalyst::Controller::SimpleCAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Controller::SimpleCAS
CPAN shell
perl -MCPAN -e shell install Catalyst::Controller::SimpleCAS
For more information on module installation, please visit the detailed CPAN module installation guide.