Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 40b46a6

Browse files
authored
Update README.md
1 parent 70bf9e4 commit 40b46a6

File tree

1 file changed

+69
-2
lines changed

1 file changed

+69
-2
lines changed

README.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
1-
# laravel-acr-cloud
2-
Laravel Package for ACR Cloud
1+
# Laravel ACR Cloud Package
2+
3+
## Installation
4+
5+
### Compatibility
6+
7+
This package is using the ACR Cloud php 7.2 executible.
8+
This requires Laravel 5.6 or greater
9+
10+
### Composer
11+
12+
```
13+
composer require sharpstream/acrcloud:1.0
14+
```
15+
16+
### Add acrcloud_extr_tool.so
17+
* Copy acrcloud_extr_tool.so file to your extensions directory. Found by viewing your php.ini and searching for : extension_dir
18+
* Add extension=acrcloud_extr_tool.so to the bottom of php.ini
19+
* Restart PHP
20+
21+
## Envirnonment Variables
22+
This package requires a few variables to be added to your projects .env file. All of the values for which can be found by logging into your ACR Cloud Account.
23+
24+
Your host and request url will differ dependend on your region.
25+
26+
```
27+
ACR_HOST=http://identify-eu-west-1.acrcloud.com
28+
ACR_REQUEST_URL=http://identify-eu-west-1.acrcloud.com/v1/identify
29+
ACR_ACCESS_KEY=***************************
30+
ACR_ACCESS_SECRET=***************************
31+
```
32+
33+
## Example Controller
34+
35+
```
36+
<?php
37+
namespace App\Http\Controllers;
38+
39+
use App\Storage;
40+
use SharpStream\AcrCloud\Metadata;
41+
use SharpStream\AcrCloud\Formatter;
42+
use Illuminate\Support\Facades\Cache;
43+
44+
class AcrCloudController extends Controller
45+
{
46+
public function show($file)
47+
{
48+
// File is the path to your file
49+
if (Cache::has(self::ACR_CACHE_PREFIX . $file->name)) {
50+
return response()->json(Cache::get(self::ACR_CACHE_PREFIX . $file->name), 200);
51+
}
52+
53+
$recognizerInstance = new Metadata;
54+
55+
$fileData = $recognizerInstance->recognizeFile($file, 10, 10);
56+
$metadata = Formatter::translateResponse($fileData);
57+
58+
if (!empty($metadata)) {
59+
Cache::forever(self::ACR_CACHE_PREFIX . $file->name, $metadata);
60+
return response()->json($metadata, 200);
61+
}
62+
return response()->json(['errors' => ['Unable to retrieve metadata for this file']], 400);
63+
}
64+
}
65+
```
66+
67+
68+
69+

0 commit comments

Comments
 (0)