Adding a text file

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsAdding a text file
(Created page with "### Tutorial DreamFactory 2.0 allows you to expose various storage services as API Endpoints. The following storage services are currently supported. * Local Storage (conf...")
 
Line 22: Line 22:
  
 
### API Endpoints
 
### API Endpoints
 +
 +
In these examples, when using the API to create a file the destination folder is part of the URL and must have a trailing slash. The slash is what indicates it's a folder.
  
 
<pre>POST http://{url}/api/v2/{storage_service_name}/{folder}/</pre>
 
<pre>POST http://{url}/api/v2/{storage_service_name}/{folder}/</pre>

Revision as of 18:18, 20 January 2016

      1. Tutorial

DreamFactory 2.0 allows you to expose various storage services as API Endpoints. The following storage services are currently supported.

  • Local Storage (configurable to use local file system, S3, Azure, or Rackspace)
  • AWS S3
  • Azure Blob
  • OpenStack Object Storage
  • Rackspace Cloud Files
      1. Provisioning a Storage Service

All DreamFactory 2.0 instances come pre-configured with a 'Local Storage' service named 'files'. You can find this service on the admin console, under the services tab. You can also provision as many other storage services as you like using the admin console. Login to the admin console and select the 'Services' tab. Click on the 'Create' button from the left menu. On the service creation form select your storage type from the 'Service Type' drop down box (File section). Enter a short, one-word, meaningful name for your service as well as a label and description. Depending on which storage type you pick, you will need to enter the service configuration values on the 'Config' tab. Create your storage service after entering all your configuration values. Your storage service is now ready for action. For this tutorial, we will use the pre-configured storage service - 'files'.

      1. API Endpoints

In these examples, when using the API to create a file the destination folder is part of the URL and must have a trailing slash. The slash is what indicates it's a folder.

POST http://{url}/api/v2/{storage_service_name}/{folder}/

Request Body:

{
    "resource":[
        {
            "name":"{file}",
            "type":"file",
            "content":"{content}"
        }
    ]
}
      1. Example
  • Storage service: files
  • Folder: docs
  • File: hello.txt
  • Content: Hello World!
  • Request Body:
{
    "resource":[
        {
            "name":"hello.txt",
            "type":"file",
            "content":"Hello World!"
        }
    ]
}
  • Request URL:
POST http://foo.com/api/v2/files/docs/