Skip to content

Latest commit

 

History

History
80 lines (60 loc) · 1.82 KB

digitalocean-driver.md

File metadata and controls

80 lines (60 loc) · 1.82 KB

DigitalOcean

{% hint style="info" %} Github https://github.com/rfschubert/masonite-digitalocean-driver
Pypi https://pypi.org/project/masonite-digitalocean-driver {% endhint %}

Requirements

In order to use the Dropbox upload driver, you'll need:

  • Python 3.4+
  • Pip3
  • Masonite 2.0+
  • boto3

Getting Started

Installation

{% code-tabs %} {% code-tabs-item title="terminal" %}

$ pip install masonite-digitalocean-driver

{% endcode-tabs-item %} {% endcode-tabs %}

Masonite Setup

Environment

Paste the access token in your project's .env file along with the folder name where you want your uploads to be saved.

{% code-tabs %} {% code-tabs-item title=".env" %}

DO_REGION=nyc3
DO_ENDPOINT=https://nyc3.digitaloceanspaces.com
DO_SPACE=hello-space
DO_CLIENT=JIGJKDIKEL22VMKKIUYE
DO_SECRET=+zs11IroZZpoiGK4h+quKKsjXwP67ssOOAD2gawvNmX

{% endcode-tabs-item %} {% endcode-tabs %}

Service Provider

Add the DigitalOceanProvider to PROVIDERS in the config/providers.py file.

{% code-tabs %} {% code-tabs-item title="config/providers.py" %}

from masonite.contrib.digitalocean.providers import DigitalOceanProvider

PROVIDERS = [
    # Third Party Providers
    DigitalOceanProvider,
]

{% endcode-tabs-item %} {% endcode-tabs %}

Using the Driver

{% code-tabs %} {% code-tabs-item title="ActivityController.py" %}

class ActivityController:

    def create(self, View):
        return View('admin/activities/new')

    def store(self, Upload, Request):
        Upload.driver('digitalocean').store(Request.input('file_upload'))
        return Request.redirect_to('dashboard')

{% endcode-tabs-item %} {% endcode-tabs %}