1. Go to this page and download the library: Download microwin7/texture-provider 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/ */
microwin7 / texture-provider example snippets
Route::prefix('skins')->middleware('auth')->group(function () {
// Маршрут для upload с перенаправлением на API TextureProvider'a
Route::post('upload', function () {
$user = Auth::user();
$link = env('TEXTURE_PROVIDER_URL') . '/api/upload/' . strtoupper(request()->get('type'));
// Перенаправляем запрос на API TextureProvider'a, передавая все данные и добавляя Bearer токен в заголовки
$response = Http::withToken(env('TEXTURE_PROVIDER_BEARER_TOKEN'))
->attach('file', file_get_contents(request()
->file('file')), 'texture.png')
->asMultipart()
->post(
$link,
[
'username' => $user->login,
'uuid' => $user->uuid
]
);
// Возвращаем ответ от стороннего API
return Response::json($response->successful() ? array_merge(
$response->json(),
[
'success' => true,
'message' => 'Загрузка успешна'
]
) : [
'success' => false,
'message' => $response->json()['error']
], $response->status());
});
});