diff --git a/doc/filestore.rst b/doc/filestore.rst index 7e38e31658c..cbd77c14168 100644 --- a/doc/filestore.rst +++ b/doc/filestore.rst @@ -1,5 +1,5 @@ ========================== -FileStore and File Uploads +FileStore and file uploads ========================== CKAN allows users to upload files directly to it against a resource or images @@ -11,9 +11,9 @@ displayed against groups and organizations. details on how to migrate). This is to give CKAN more control over the files and make access control possible. -------------------------------------------- -Setup File Uploads -------------------------------------------- +------------------ +Setup file uploads +------------------ To setup CKAN's FileStore with local file storage: @@ -28,11 +28,11 @@ To setup CKAN's FileStore with local file storage: .. parsed-literal:: - ckan.storage_dir = |storage_path| + ckan.storage_path = |storage_path| -3. Set the permissions of the ``storage_path``. For example if you're running +3. Set the permissions of the :ref:`ckan.storage_path`. For example if you're running CKAN with Apache, then Apache's user (``www-data`` on Ubuntu) must have - read, write and execute permissions for the ``storage_path``: + read, write and execute permissions for the :ref:`ckan.storage_path`: .. parsed-literal:: @@ -47,45 +47,46 @@ To setup CKAN's FileStore with local file storage: ----------------------- -FileStore Web Interface +FileStore web interface ----------------------- Upload of files to storage is integrated directly into the Dataset creation and editing system with files being associated to Resources. ------------------------ +------------- FileStore API ------------------------ +------------- .. versionchanged:: 2.2 The previous API has been deprecated although should still work if you where using local file storage. -The api is part of the resource_create and resource_update action api -functions. You can post mutipart/form-data to the api and the key, value -pairs will treated as as if they are a json object. +The API is part of the :py:func:`~ckan.logic.action.create.resource_create` and +:py:func:`~ckan.logic.action.update.resource_update` action API +functions. You can post mutipart/form-data to the API and the key, value +pairs will treated as as if they are a JSON object. The extra key ``upload`` is used to actually post the binary data. Curl automatically puts the multipart-form-data heading when using the ``--form`` option: - .. parsed-literal:: +.. parsed-literal:: - curl -H'Authorization: your-api-key' 'http://yourhost/api/action/resource_create' --form upload=@filetoupload --form package_id=my_dataset + curl -H'Authorization: your-api-key' 'http://yourhost/api/action/resource_create' --form upload=@filetoupload --form package_id=my_dataset -The python requests library used the files parameter and automatically sets +The Python requests library used the files parameter and automatically sets the multipart/form-data header too: - .. parsed-literal:: +.. parsed-literal:: - import requests - requests.post('http://0.0.0.0:5000/api/action/resource_create', - data={"package_id":"my_dataset}", - headers={"X-CKAN-API-Key": "21a47217-6d7b-49c5-88f9-72ebd5a4d4bb"}, - files=[('upload', file('/path/to/file/to/upload.csv'))]) + import requests + requests.post('http://0.0.0.0:5000/api/action/resource_create', + data={"package_id":"my_dataset}", + headers={"X-CKAN-API-Key": "21a47217-6d7b-49c5-88f9-72ebd5a4d4bb"}, + files=[('upload', file('/path/to/file/to/upload.csv'))]) -With resource_update, if you want to override a file you just need -to set the upload field again:: +With :py:func:`~ckan.logic.action.update.resource_update`, if you want to +override a file you just need to set the upload field again:: curl -H'Authorization: your-api-key' 'http://yourhost/api/action/resource_update' --form upload=@newfiletoupload --form id=resourceid @@ -111,7 +112,7 @@ but if you want to move the remote storage documents to the local storage you wi run the migration also. In order to migrate make sure your CKAN instance is running as the script will -request the data from the instance using apis. You need to run the following +request the data from the instance using APIs. You need to run the following on the command line todo the migration:: paster db migrate-filestore