File Optimizer

Introduction


File optimizer function is used to optimize files for various mime type like Image,Pdf. It can be used to optimize file from client and store it to various storage platform like S3,Digitalocean Spaces and many others.

  • Supported types are Pdf,jpeg jpg jfif png bmp gif pnm tiff svg

Endpoint

Post
   https://api.oyyi.xyz/v1/optimize

Parameters

  • file REQUIRED
    • Type: File or uuid
    • UUID can be id of previous conversion so that you don't have to re-upload file to server, and it will save network resource and timing.
      Max Size Allowed for file is 100MB by default. If you need more, you ask us to increase it for you. 429 Error will be return otherwise
  • Extra Parameter

    Apart from these you can also all available common parameter available for media processing request. See Here

Example

Python
import requestsurl = $BASE_URL/optimizetoken = 'your_bearer_token_here'headers = {'Authorization': f'Bearer {token}'}files = {'file': open('example_file.jpg', 'rb')}response = requests.post(url, headers=headers, files=files)print(response.text)
Javascript
const axios = require('axios');const url = $BASE_URL/optimize;const token = 'your_bearer_token_here';const formData = new FormData();formData.append('file', YOUR FILE);const config = {  headers: {    'Authorization': `Bearer ${token}`,    'Content-Type': 'multipart/form-data'  }};axios.post(url, formData, config)  .then(response => console.log(response.data))  .catch(error => console.error(error));
Dart
import 'dart:io';import 'package:http/http.dart' as http;void main() async {  var url = Uri.parse($BASE_URL/optimize);  var token = 'your_bearer_token_here';  var request = http.MultipartRequest('POST', url)    ..headers['Authorization'] = 'Bearer $token'    ..files.add(await http.MultipartFile.fromPath('file', 'example_file.jpg'));  var response = await request.send();  print(await response.stream.bytesToString());}
Laravel
use Illuminate\Http\Client\Response;use Illuminate\Support\Facades\Http;$url = '$BASE_URL/optimize';$token = 'your_bearer_token_here';$response = Http::withHeaders([    'Authorization' => 'Bearer ' . $token,])->attach('file', $file_path)->post($url);if ($response->successful()) {    $data = $response->json();} else {m    $message = $response->json()['message']m;}
Curl
curl -X POST \  -H 'Authorization: Bearer your_bearer_token_here' \  -F 'file=@/path/to/your/file' \  $BASE_URL/optimize

::

Response

Default
{  "data": {    "id": "4c27a32a-8d3e-4ad4-a19c-91063cb0483f",       "converted_file": "your_random_converted_file.jpg",    "created_at": "2023-02-22T06:25:35.659015Z",     "status": "queued"  }}
Upload Original
{  "data": {    "id": "dd4409a1-68bf-4e0f-821a-498e19c6fdcc",        "converted_file": "your_random_converted_file.jpg",        "original_file": "original.jpg",    "created_at": "2023-02-22T06:26:53.031758Z",    "status": "done"  }}
You can visit here to know to you can fetch file by file id.