Laravel 5.2 working with Dropbox API to upload file using league/flysystem-dropbox package with example

Laravel 5.2 working with Dropbox API to upload file using league/flysystem-dropbox package with example

Working with Dropbox API to upload file using league/flysystem-dropbox package with example in Laravel 5.2

Here is a sample example to upload file over dropbox, just follow few step to backup your file data in Laravel 5.2 using league/flysystem-dropbox package.

Benefits with Dropbox which is know as cloud storage is freely upload your files into cloud storage instead of server that means you can backup your application or backup your database to dropbox in Laravel 5.2.

Dropbox have many awesome features to working with files as you can easily share your files with friends or upload bulk of files which take less time to uploading, rename your files, edit your files and many more features there.

Flysystem is a filesystem that give you permission to swap out a local filesystem for a remote one.

There are 3 simple steps to done with file upload in dropbox. Follow each step to store or upload file in your dropbox account using Dropbox Client API.

Step1: Install league/flysystem-dropbox package

Its very easy to install league/flysystem-dropbox package with composer, you have to simply fire this command to use Dropbox Client API.

composer require league/flysystem-dropbox
Step2: Create a Dropbox API App

You will need to have app_token and app_secret to authenticate your account with Dropbox. So create a Dropbox API App first to get app_token and app_secret.

Click here to create Dropbox API App

Now you will get your token and secret key after creating Dropbox API App, just copy that token and put in your filesystems.php within config directory.

  1. 'dropbox' => [
  2. 'driver' => 'dropbox',
  3. 'key' => 'your-key',
  4. 'secret' => 'your-secret'
  5. ],
Step3: Route and Controller

Put following line of code in your routes.php

  1. Route::get('dropbox-upload-file', 'FileController@dropboxFileUpload');

Now create a method in your controller to upload file in dropbox. Here I am creating a FileController and within this controller i add dropboxFileUpload method.

Put these code in your controller.

  1. public function dropboxFileUpload()
  2. {
  3. $Client = new Client(config('filesystems.dropbox.key'), config('filesystems.dropbox.secret'));
  4. $file = fopen(public_path('images/angular_crud.png'), 'rb');
  5. $size = filesize(public_path('images/angular_crud.png'));
  6. $dropboxFileName = '/dropboxfile-name.png';
  7. $Client->uploadFile($dropboxFileName,WriteMode::add(),$file, $size);
  8. }

Don't forget to use traits to include package at top of controller.

  1. use Dropbox\Client;
  2. use Dropbox\WriteMode;

If you want to store the file link in your database then use these function to view share link.

  1. $Client->createShareableLink($dropboxFileName);
  2. $Client->createTemporaryDirectLink($dropboxFileName);

Now you can use this example to upload file in dropbox in Laravel 5.2

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
hatay escort nevsehir escort nigde escort kirikkale escort batman escort osmaniye escort kirklareli escort tokat escort rize escort adiyaman escort gumushane escort batman escort
porno izle
cialis satış cialis fiyat cialis 20 mg cialis 100 mg cialis 5 mg fiyat
sohbet okey oyna
ankara escort marmaris escort bursa escort mersin escort antalya escort izmir escort samsun escort bodrum escort çeşme escort kuşadası escort adana escort eskişehir escort gaziantep escort esenyurt escort pendik escort tuzla escort fatih escort ümraniye escort mecidiyeköy escort kartal escort bahçelievler escort bahçeşehir escort ataşehir escort bakırköy escort nişantaşı escort avcılar escort büyükçekmece escort kurtkoy escort konya escort beşiktaş escort taksim escort beylikdüzü escort malatya escort sakarya escort şişli escort maltepe escort kadıköy escort ataköy escort bostancı escort şirinevler escort bağcılar escort üsküdar escort etiler escort başaksehir escort ortaköy escort kağıthane escort sultangazi escort halkalı escort çekmeköy escort şaşkınbakkal escort mamak escort sincan escort keçiören escort çankaya escort beypazarı escort akyurt escort pursaklar escort kahramankazan escort göztepe escort alsancak escort bornova escort buca escort karabaglar escort karşıyaka escort konak escort narlıdere escort izmit escort başiskele escort kandira escort körfez escort karamürsel escort dilovası escort gölcük escort gebze escort kocaeli escort kayseri escort elazığ escort denizli escort diyarbakir escort adana escort ankara escort izmir escort antalya escort gaziantep escort kayseri escort konya escort mersin escort denizli escort kocaeli escort diyarbakır escort