Skip to content

Commit

Permalink
Merge pull request #42 from HE-Arc/editor_dragdrop
Browse files Browse the repository at this point in the history
Editor dragdrop
  • Loading branch information
Haldenwat authored Dec 16, 2018
2 parents 7bb7373 + 4d03fa9 commit 3a3bf24
Show file tree
Hide file tree
Showing 25 changed files with 4,007 additions and 2,994 deletions.
32 changes: 32 additions & 0 deletions app/Http/Controllers/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use GuzzleHttp\Client;

class FileController extends Controller
{
Expand Down Expand Up @@ -198,4 +199,35 @@ public function newFile()
return redirect(route('files.edit', $idNewFile));
}

/**
* Upload the image to imgur and return a link to it
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function uploadImage(Request $request)
{
$image = $request->getContent();
$client = new Client();
$headers = ['Authorization' => 'Client-ID '.config('services.imgur.clientID')];
$body = [
'name' => 'image',
'contents' => $image
];
$response = $client->request('POST', 'https://api.imgur.com/3/image',
['headers' => $headers, 'multipart' => [$body]]);

$data = json_decode($response->getBody(), true);


return response()->json([
'link' => $data['data']['link'],
'state' => true
]);




}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"php": "^7.1.3",
"doctrine/dbal": "^2.8",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0",
"symfony/yaml": "^4.1"
Expand Down
Loading

0 comments on commit 3a3bf24

Please sign in to comment.