---
title: "View source for Local File Storage - DreamFactory Wiki"
source: "http://wiki.dreamfactory.com/index.php?action=edit&title=Local_File_Storage"
canonical_url: "http://wiki.dreamfactory.com/index.php?action=edit&title=Local_File_Storage"
converted_at: "2026-11-23T01:11:51.703Z"
format: "markdown"
converted_by: "html-to-md-ai"
---
[]()
	
	
	
	# View source for Local File Storage

	
		
		← [Local File Storage](/Local_File_Storage)
		
		
		
		[Jump to navigation](#mw-head)
		[Jump to search](#searchInput)
		You do not have permission to edit this page, for the following reason:

The action you have requested is limited to users in the group: [Users](/index.php?title=DreamFactory_Wiki:Users&action=edit&redlink=1).---

You can view and copy the source of this page.

{{#seo:
|title=Local File Storage - DreamFactory Documentation
|title_mode=replace
|description=Create a REST API for local file storage on the DreamFactory server with full CRUD operations
|keywords=local storage, file storage, REST API, file upload, file management, server storage
|og:title=Local File Storage
|og:type=article
|og:site_name=DreamFactory Documentation
|og:description=Create a REST API for local file storage on the DreamFactory server with full CRUD operations
}}
'''Create a REST API for local file storage on the DreamFactory server with full CRUD operations'''

&lt;span id="local-file-storage">&lt;/span>
= Local File Storage =

DreamFactory's Local File Storage connector provides REST API access to files stored directly on the DreamFactory server's filesystem. This is ideal for development, testing, and scenarios where cloud storage is not required.

-----

&lt;span id="use-cases">&lt;/span>
== Use Cases ==

* '''Development and testing''': Quick setup without external dependencies
* '''Application assets''': Store images, documents, and static files
* '''Temporary file processing''': Upload files for server-side processing
* '''Small-scale deployments''': When cloud storage is unnecessary overhead
* '''Air-gapped environments''': No internet connectivity required

{{Warning|title=Production Considerations|For production deployments, consider cloud storage (S3, Azure Blob) for: - Horizontal scaling (multiple DreamFactory instances) - Backup and disaster recovery - CDN integration - Larger storage capacity}}

-----

&lt;span id="creating-a-local-file-storage-service">&lt;/span>
== Creating a Local File Storage Service ==

&lt;span id="step-1-navigate-to-api-generation">&lt;/span>
=== Step 1: Navigate to API Generation ===

Log in to your DreamFactory instance using an administrator account and select the '''API Generation &amp;amp; Connections''' tab. Set your API Type to '''File'''.

&lt;span id="step-2-create-new-service">&lt;/span>
=== Step 2: Create New Service ===

Click the purple plus button to create a new file service, then search for and select '''Local File Storage'''.

&lt;span id="step-3-configure-service-details">&lt;/span>
=== Step 3: Configure Service Details ===

{| class="wikitable"
|-
! Field
! Description
! Example
|-
| Name
| Service name (lowercase, alphanumeric, used in API URL)
| &lt;code>files&lt;/code>
|-
| Label
| Display name in admin console
| &lt;code>Local Files&lt;/code>
|-
| Description
| Service description
| &lt;code>Local file storage for application assets&lt;/code>
|}

&lt;span id="step-4-configure-storage-path">&lt;/span>
=== Step 4: Configure Storage Path ===

In the '''Config''' section, specify the root folder path:

{| class="wikitable"
|-
! Field
! Description
! Example
|-
| Root Folder
| Absolute path on the server
| &lt;code>/var/www/storage/files&lt;/code>
|}

{{Warning|title=Permissions|Ensure the web server user (e.g., &lt;code>www-data&lt;/code>, &lt;code>nginx&lt;/code>) has read/write permissions on the specified root folder:

&lt;syntaxhighlight lang="bash">sudo mkdir -p /var/www/storage/files
sudo chown -R www-data:www-data /var/www/storage/files
sudo chmod -R 755 /var/www/storage/files&lt;/syntaxhighlight>}}
&lt;span id="step-5-save-and-test">&lt;/span>
=== Step 5: Save and Test ===

Click '''Save''' to create the service. Navigate to '''API Docs''' to view the generated endpoints and test operations.

-----

&lt;span id="configuration-options">&lt;/span>
== Configuration Options ==

{| class="wikitable"
|-
! Field
! Type
! Required
! Default
! Description
|-
| &lt;code>root_folder&lt;/code>
| string
| Yes
| -
| Absolute path to the storage directory
|-
| &lt;code>public_path&lt;/code>
| string
| No
| -
| Public URL path if files are web-accessible
|-
| &lt;code>is_public&lt;/code>
| boolean
| No
| false
| Allow unauthenticated file downloads
|}

&lt;span id="advanced-options">&lt;/span>
=== Advanced Options ===

{| class="wikitable"
|-
! Field
! Type
! Default
! Description
|-
| &lt;code>cache_enabled&lt;/code>
| boolean
| false
| Enable response caching
|-
| &lt;code>cache_ttl&lt;/code>
| integer
| 0
| Cache time-to-live in seconds
|-
| &lt;code>allow_upsert&lt;/code>
| boolean
| true
| Allow PUT to create new files
|}

-----

&lt;span id="api-endpoints">&lt;/span>
== API Endpoints ==

Once configured, DreamFactory generates these endpoints:

{| class="wikitable"
|-
! Method
! Endpoint
! Description
|-
| &lt;code>GET&lt;/code>
| &lt;code>/api/v2/{service_name}/&lt;/code>
| List root directory
|-
| &lt;code>GET&lt;/code>
| &lt;code>/api/v2/{service_name}/{path}/&lt;/code>
| List folder contents
|-
| &lt;code>GET&lt;/code>
| &lt;code>/api/v2/{service_name}/{path}&lt;/code>
| Download file
|-
| &lt;code>POST&lt;/code>
| &lt;code>/api/v2/{service_name}/&lt;/code>
| Create folder or upload file
|-
| &lt;code>POST&lt;/code>
| &lt;code>/api/v2/{service_name}/{path}/&lt;/code>
| Create subfolder or upload file
|-
| &lt;code>PUT&lt;/code>
| &lt;code>/api/v2/{service_name}/{path}&lt;/code>
| Replace file contents
|-
| &lt;code>PATCH&lt;/code>
| &lt;code>/api/v2/{service_name}/{path}&lt;/code>
| Update file properties
|-
| &lt;code>DELETE&lt;/code>
| &lt;code>/api/v2/{service_name}/{path}&lt;/code>
| Delete file or folder
|}

-----

&lt;span id="api-examples">&lt;/span>
== API Examples ==

&lt;span id="list-directory-contents">&lt;/span>
=== List Directory Contents ===

&lt;syntaxhighlight lang="bash">curl -X GET "https://example.com/api/v2/files/" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY"&lt;/syntaxhighlight>
'''Response:'''

&lt;syntaxhighlight lang="json">{
  "resource": [
    {
      "path": "images/",
      "type": "folder",
      "name": "images",
      "last_modified": "2026-02-10T14:30:00Z"
    },
    {
      "path": "config.json",
      "type": "file",
      "name": "config.json",
      "content_type": "application/json",
      "content_length": 2048,
      "last_modified": "2026-02-09T10:15:00Z"
    }
  ]
}&lt;/syntaxhighlight>
&lt;span id="create-a-folder">&lt;/span>
=== Create a Folder ===

&lt;syntaxhighlight lang="bash">curl -X POST "https://example.com/api/v2/files/" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY" \
  -H "X-Folder-Name: documents"&lt;/syntaxhighlight>
'''Response:'''

&lt;syntaxhighlight lang="json">{
  "name": "documents",
  "path": "documents/"
}&lt;/syntaxhighlight>
&lt;span id="upload-a-file">&lt;/span>
=== Upload a File ===

Using the file path in the URL:

&lt;syntaxhighlight lang="bash">curl -X POST "https://example.com/api/v2/files/documents/report.pdf" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/pdf" \
  --data-binary @report.pdf&lt;/syntaxhighlight>
Using the &lt;code>X-File-Name&lt;/code> header:

&lt;syntaxhighlight lang="bash">curl -X POST "https://example.com/api/v2/files/documents/" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY" \
  -H "X-File-Name: report.pdf" \
  -H "Content-Type: application/pdf" \
  --data-binary @report.pdf&lt;/syntaxhighlight>
'''Response:'''

&lt;syntaxhighlight lang="json">{
  "name": "report.pdf",
  "path": "documents/report.pdf",
  "content_type": "application/pdf",
  "content_length": 102400
}&lt;/syntaxhighlight>
&lt;span id="download-a-file">&lt;/span>
=== Download a File ===

&lt;syntaxhighlight lang="bash">curl -X GET "https://example.com/api/v2/files/documents/report.pdf" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY" \
  -o report.pdf&lt;/syntaxhighlight>
&lt;span id="get-file-properties">&lt;/span>
=== Get File Properties ===

Add &lt;code>?include_properties=true&lt;/code> to get metadata without downloading:

&lt;syntaxhighlight lang="bash">curl -X GET "https://example.com/api/v2/files/documents/report.pdf?include_properties=true" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY"&lt;/syntaxhighlight>
'''Response:'''

&lt;syntaxhighlight lang="json">{
  "path": "documents/report.pdf",
  "name": "report.pdf",
  "type": "file",
  "content_type": "application/pdf",
  "content_length": 102400,
  "last_modified": "2026-02-10T15:45:00Z"
}&lt;/syntaxhighlight>
&lt;span id="delete-a-file">&lt;/span>
=== Delete a File ===

&lt;syntaxhighlight lang="bash">curl -X DELETE "https://example.com/api/v2/files/documents/old-report.pdf" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY"&lt;/syntaxhighlight>
&lt;span id="delete-a-folder">&lt;/span>
=== Delete a Folder ===

Add &lt;code>?force=true&lt;/code> to delete non-empty folders:

&lt;syntaxhighlight lang="bash">curl -X DELETE "https://example.com/api/v2/files/old-documents/?force=true" \
  -H "X-DreamFactory-API-Key: YOUR_API_KEY"&lt;/syntaxhighlight>

-----

&lt;span id="file-upload-limits">&lt;/span>
== File Upload Limits ==

Upload size limits are controlled by your web server and PHP configuration, not DreamFactory.

&lt;span id="nginx-configuration">&lt;/span>
=== Nginx Configuration ===

Add to your &lt;code>nginx.conf&lt;/code> or site configuration:

&lt;syntaxhighlight lang="nginx">client_max_body_size 100M;&lt;/syntaxhighlight>
&lt;span id="php-configuration">&lt;/span>
=== PHP Configuration ===

Modify &lt;code>php.ini&lt;/code>:

&lt;syntaxhighlight lang="ini">upload_max_filesize = 100M
post_max_size = 105M&lt;/syntaxhighlight>
Restart your web server and PHP-FPM after making changes.

-----

&lt;span id="common-errors">&lt;/span>
== Common Errors ==

{| class="wikitable"
|-
! Error Code
! Message
! Cause
! Solution
|-
| 400
| Invalid path
| Path contains invalid characters
| Use alphanumeric characters, dashes, underscores
|-
| 403
| Forbidden
| Permission denied on filesystem
| Check folder permissions for web server user
|-
| 404
| Not Found
| File or folder does not exist
| Verify the path exists on the server
|-
| 409
| Conflict
| File already exists
| Use PUT to overwrite or delete first
|-
| 413
| Payload Too Large
| File exceeds upload limit
| Increase server upload limits
|-
| 500
| Internal Server Error
| Server-side error
| Check DreamFactory logs for details
|}

&lt;span id="troubleshooting-permissions">&lt;/span>
=== Troubleshooting Permissions ===

If you receive 403 errors, verify filesystem permissions:

&lt;syntaxhighlight lang="bash"># Check current permissions
ls -la /var/www/storage/files

# Fix ownership
sudo chown -R www-data:www-data /var/www/storage/files

# Fix permissions (directories need execute bit)
sudo find /var/www/storage/files -type d -exec chmod 755 {} \;
sudo find /var/www/storage/files -type f -exec chmod 644 {} \;&lt;/syntaxhighlight>

-----

&lt;span id="security-considerations">&lt;/span>
== Security Considerations ==

&lt;span id="path-traversal-protection">&lt;/span>
=== Path Traversal Protection ===

DreamFactory sanitizes paths to prevent directory traversal attacks. Requests containing &lt;code>../&lt;/code> or absolute paths outside the root folder are rejected.

&lt;span id="role-based-access-control">&lt;/span>
=== Role-Based Access Control ===

Configure RBAC to restrict file operations:

# Navigate to '''Roles''' in the admin console
# Select or create a role
# Under '''Access''', add the file service
# Configure allowed paths and operations:
#* '''GET''' for read-only access
#* '''POST''' for upload-only
#* '''DELETE''' to allow deletions

Example: Allow uploads to &lt;code>/uploads/&lt;/code> but not access to &lt;code>/config/&lt;/code>:

{| class="wikitable"
|-
! Path
! Methods
|-
| &lt;code>uploads/*&lt;/code>
| GET, POST
|-
| &lt;code>public/*&lt;/code>
| GET
|}

-----

&lt;span id="next-steps">&lt;/span>
== Next Steps ==

* '''[[Aws_S3|AWS S3]]''': Migrate to cloud storage for production
* '''[[File_Services_Overview|File Services Overview]]''': Compare all file storage options
* '''[[Security/Role_Based_Access|Role-Based Access Control]]''': Configure fine-grained permissions

[[Category:Local_Storage]]
[[Category:File_Storage]]
[[Category:Rest_Api]]
[[Category:API]]
[[Category:Difficulty_Beginner]]

[[Category:API]]
[[Category:File_Storage]]
Template used on this page:

- [Template:Warning](/Template:Warning) ([view source](/index.php?title=Template:Warning&action=edit))

Return to [Local File Storage](/Local_File_Storage).

Retrieved from "[https://wiki.dreamfactory.com/Local_File_Storage](https://wiki.dreamfactory.com/Local_File_Storage)"