You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use OSS\OssClient;
……
$accessKeyId = 'your access key id for oss';
$accessKeySecret = 'your access key secret for oss';
$bucket = 'the bucket you use';
$endpoint = 'oss-cn-shanghai.aliyuncs.com';
$objectPath = 'path used in oss bucket for your file';
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
$ossClient->uploadFile($bucket, $objectPath, 'absolute path of the file that you want to recognize character from');
// $ossClient->deleteObject($bucket, $objectPath);
} catch (Exception $e) {
throw new Exception("Failed to upload file for recognizing character. Exception message is " . $e->getMessage());
}
$fileOssUrl = 'https://' . $bucket . '.' . $endpoint . '/' . $objectPath;
自行实现文字识别API的调用,首先需要将要识别的图片上传到阿里云的上海oss,得到上传的图片得到的oss对象的url,参考代码如下
然后生成调用文字识别API所需的签名,使用包含上边得到的oss对象url在内的若干参数,调用文字识别API(使用了GuzzleHttp)
如果在得到文字识别结果之后,希望删除oss中的对象,使用第一段示例代码中注释掉的代码即可
The text was updated successfully, but these errors were encountered: