-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b423341
commit 2424843
Showing
4 changed files
with
57 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,91 @@ | ||
# ckanext-files | ||
|
||
Upload and use standalone files. No resources, no datasets, just files. | ||
|
||
Files as first-class citizens of CKAN. Upload, manage, remove files directly | ||
and attach them to datasets, resources, etc. | ||
|
||
## Requirements | ||
|
||
|
||
Compatibility with core CKAN versions: | ||
|
||
| CKAN version | Compatible? | | ||
|--------------|-------------| | ||
| 2.8 | yes | | ||
| 2.9 | yes | | ||
| 2.10 | yes | | ||
| master | yes | | ||
|
||
CKAN v2.8 and v2.9 are supported by ckanext-files v0.2. Starting from v1.0 this | ||
extension switches to CKAN support policy of two latest CKAN releases. I.e, | ||
ckanext-files v1.0 supports only CKAN v2.10 and v2.11. | ||
|
||
alembic==1.4 | ||
v0.2 will not receive any new features, only bug-fixes. | ||
|
||
It's recommended to install the extension via pip, so you probably have all the | ||
requirements pinned already. If you are using GitHub version of this extension, | ||
stick to the vX.Y.Z tags to avoid breaking changes. Check the changelog before | ||
upgrading the extension. | ||
|
||
## Installation | ||
|
||
To install ckanext-files: | ||
|
||
1. Install the extension | ||
```sh | ||
# minimal installation | ||
pip install ckanext-files | ||
|
||
pip install ckanext-files | ||
# Google Cloud Storage support | ||
pip install 'ckanext-files[gcstorage]' | ||
``` | ||
|
||
1. Add `files` to the `ckan.plugins` setting in your CKAN | ||
config file. | ||
|
||
1. Updgrade DB | ||
|
||
ckan db upgrade -p files | ||
1. Run DB migrations | ||
```sh | ||
# CKAN >= v2.9 with alembic | ||
ckan db upgrade -p files | ||
## API | ||
# CKAN == v2.8 | ||
paster --plugin=ckanext-files files -c ckan.ini initdb | ||
``` | ||
|
||
Each API action has corresponding auth-function with the same name. By default | ||
only sysadmin can pass auth check(unless different behavior explicitly | ||
mentioned in action description). Whenever you are using this extension feel | ||
free to redefine these auth-functions using `tk.chained_auth_function`. | ||
## Usage | ||
|
||
Some of API actions has `kind` parameter. It defines which folder will store | ||
the file, which config options will be applied, etc. Default value is | ||
`ckanext_files_file` | ||
|
||
* `files_file_create` | ||
|
||
Create new `file` entity. | ||
## Configuration | ||
|
||
Parameters: | ||
* `name` Name for the uploaded file. | ||
* `upload` File itself | ||
* `kind` Type of uploaded file. | ||
* `extras` Dictionary with any details that can be used for your needs. | ||
There are two types of config options for ckanext-files: | ||
* Global configuration affects the common behavior of the extension | ||
* Storage configuration changes behavior of the specific storage and never | ||
affects anything outside of the storage | ||
|
||
Returns: | ||
* `id: str` Unique ID of the new `file`. | ||
* `name: str` Name for the `file`. | ||
* `url: str` File itself | ||
* `kind: str` Type of uploaded file. | ||
* `uploaded_at: datetime.datetime` File creation date | ||
* `extras: Optional[dict[str, Any]]` Dictionary with any details that can be used for your needs. | ||
Depending on the type of the storage, available options for storage change. For | ||
example, `files:fs` storage type requires `path` option that controls | ||
filesystem path where uploads are stored. `files:redis` storage type accepts | ||
`prefix` option that defines Redis' key prefix of files stored in Redis. All | ||
storage specific options always have form | ||
`ckanext.files.storage.<STORAGE>.<OPTION>`: | ||
* `files_file_show` | ||
```ini | ||
ckanext.files.storage.memory.prefix = xxx: | ||
# or | ||
ckanext.files.storage.my_drive.path = /tmp/hello | ||
``` | ||
Show `file` detiles. | ||
Below is the list of non-storage specific options. Details of the specific | ||
storage type can be found in the dedicated section of the storage type. | ||
Parameters: | ||
* `id: str`: ID or name of file entity | ||
```ini | ||
Returns: same as `files_file_create` | ||
# Default storage used for upload when no explicit storage specified | ||
# (optional, default: default) | ||
ckanext.files.default_storage = default | ||
# Configuration of the named storage. | ||
# (optional, default: ) | ||
ckanext.files.storage.<NAME>.<OPTION> = | ||
## Config settings | ||
# Allowed size for uploaded file in MB. | ||
# (optional, default: 2). | ||
ckanext.files.kind.<KIND>.max_size = 2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters