Welcome to TrinityTuts, In this latest blog, I’m going to explain to you how we can upload large statics file to Digital Ocean Space. Digital Ocean Space is same as AWS S3. Now for this post, I am going to use CakePHP 3 framework to do all uploading stuff. Now without wasting any time, I will explain you step by step so you can implement this in your project. You can also check video what we going to do on this project and after completing code part what we get and don’t forget to subscribe channel.

 

Steps to Setup Digital Ocean Space in your Application

Step 1. Login or Create your Digital Ocean Account.

Step 2. Step your Droplet and Set up your CakePHP 3 application.

Step 3. Now after all the setup is done we need to create a space. Click on create on top of the navigation bar and click on spaces as shown image below.

Now fill all the required details select your region give the name to your space and define access to your space and click on create a space.

Step 4. Now we can create a key through which we can access our Space data from our website to do so click on API link in top of navigation bar and after click scroll to bottom and click on Generate new Keys note we are going to generate a key for Space please check below image for reference

After creating a key, note down the key and secret of space we need that information in our next steps.

Step 5. Now our space is ready and we have key and secret to access that space now we need our application to connect with that space and perform curd operation on space. So first we need to install a plugin in our CakePHP 3. To install plugin we need to SSH access to server, log in to your server and navigate to your project directory and after that run 

After running this plugin is add to your framework.

Step 6. Now open your controller and add function our you can update old function but before that, you can define this in top of file

Step 7. Now in your function where file are getting uploaded you need to add below code

And my template file contains below code

In above function, you need to define your key and secret and also define your bucket/space information. If you want to get list of object exists in your bucket you can call this function

Or if you want to make you upload private or public you can do that by simply put

That’s all 🙂 hope this post helps you. Please don’t forget to like my page and subscribe to my youtube channel Thanks.