박유성의 라라벨 블로그

Ncloud Object Storage for Laravel 본문

패키지

Ncloud Object Storage for Laravel

Matt.park 2020. 7. 16. 09:17

https://github.com/meteopark/ncloud-object-storage-laravel#ncloud-object-storage-for-laravel

 

meteopark/ncloud-object-storage-laravel

It is a package that can easily upload files through Object Storage which is a service provided by Ncloud. - meteopark/ncloud-object-storage-laravel

github.com

Ncloud Object Storage for Laravel

Latest Stable Version Total Downloads

It is a package that can easily upload files through Object Storage which is a service provided by Ncloud.

Installation

composer require meteopark/ncloud-object-storage-laravel

Set the filesystems.php

<?php

...

'disks' => [
    'ncloud' => [
        'driver'    => 's3',
        'region'    => 'kr-standard',
        'endpoint'  => 'https://kr.object.ncloudstorage.com',
        'version'   => 'latest',
        'key'       => env('NCLOUD_ACCESS_KEY_ID'),
        'secret'    => env('NCLOUD_SECRET_ACCESS_KEY'),
        'bucket'    => env('NCLOUD_BUCKET'),
    ]
]

And add environment variables.

NCLOUD_ACCESS_KEY_ID=your-ncloud-access-key-id
NCLOUD_SECRET_ACCESS_KEY=your-ncloud-secret-access-key
NCLOUD_BUCKET=your-ncloud-bucket

Basic Usage


<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Meteopark\NcloudObjectStorage\NOSFileUpload;

class FileUploadController extends Controller
{

    public function file(Request $request)
    {
        // $request->files has array ( = files[] )

        $files = (new NOSFileUpload(
                        time(), // default Str::Random(30)
                        "afolder/bfolder",
                        ['png','pdf']
                     ))->move($request->files);
    }
}

Result

 [
     {
         "org_name": "KakaoTalk_Photo_2019-05-20-18-13-15.png",
         "path": "afolder/bfolder/1559182454.png",
         "mime_type": "image/png",
         "image": {
             "width": 296,
             "height": 40
         }
     },
     {
          "org_name": "test2.pdf",
          "path": "afolder/bfolder/1559182454.pdf",
          "mime_type": "application/pdf",
     }
 ]

'패키지' 카테고리의 다른 글

Ncloud Object Storage for Laravel  (0) 2020.07.16
0 Comments
댓글쓰기 폼
Prev 1 2 3 4 5 6 7 8 Next