PHP code example of alphasnow / aliyun-oss-appserver
1. Go to this page and download the library: Download alphasnow/aliyun-oss-appserver 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/ */
use AlphaSnow\OSS\AppServer\Factory;
$token = (new Factory($config))->makeToken();
// Change the address of the direct transmission server
$token->access()->setOssHost("https://bucket.endpoint.com");
// Change the upload directory/timeout period to 60 seconds/maximum file limit to 500 MB
$token->policy()->setUserDir("upload/")->setExpireTime(60)->setMaxSize(500*1024*1024);
// Change the callback address/callback body/callback header
$token->callback()->setCallbackUrl("http://domain.com/oss-callback")
->setCallbackBody("filename=\${object}&size=\${size}&mimeType=\${mimeType}&height=\${imageInfo.height}&width=\${imageInfo.width}")
->setCallbackBodyType("application/x-www-form-urlencoded");