PHP code example of bryanthw1020 / cos-file-uploader

1. Go to this page and download the library: Download bryanthw1020/cos-file-uploader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bryanthw1020 / cos-file-uploader example snippets


# To Upload Object
CosFileUploader::uploadObject(string $bucket, string $key, string $fileName, string $base64EncodedFile, string$region = 'ap-singapore', string $schema = 'http');
## Example
CosFileUploader::uploadObject('example-bucket-123456', 'example/file/path', 'example.jpg', $base64EncodedFile);

# To Delete Single Object
CosFileUploader::deleteObject(string $bucket, string $key, string $region = 'ap-singapore', string $schema = 'http');
## Example
CosFileUploader::deleteObject('example-bucket-123456', 'example/file/path/example.jpg');

# To Delete Multiple Object
CosFileUploader::deleteObjects(string $bucket, array $keys, string $region = 'ap-singapore', string $schema = 'http');
## Example
CosFileUploader::deleteObjects('example-bucket-123456', ['example/file/path/example1.jpg', 'example/file/path/example2.jpg']);

# To Get Object URL
CosFileUploader::getObjectUrl(string $bucket, string $key, int $duration = 10, string $region = 'ap-singapore', string $schema = 'http');
## Example
CosFileUploader::getObjectUrl('example-bucket-123456', 'example/file/path/example.jpg');