PHP code example of microwin7 / texture-provider

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());
    });
});
nginx
    location /texture-provider/ {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Env-Vendor null;
        proxy_pass http://dockerTextureProvider/;
    }
nginx
upstream dockerTextureProvider {
    server 127.0.0.1:29300;
}
server {
    listen 80;
    server_name textures.ВАШ_ДОМЕН;
    charset utf-8;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Env-Vendor null;
        proxy_pass http://dockerTextureProvider/;
    }
}