/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package id.iptek.utms.agent.test;

import io.minio.GetPresignedObjectUrlArgs;
import io.minio.MinioClient;
import io.minio.http.Method;
import java.util.concurrent.TimeUnit;

/**
 *
 * @author jakar
 */
public class TestMinio {

    public static void main(String[] args) throws Exception {
        MinioClient minioClient
                = MinioClient.builder()
                        .endpoint("https://download.unifiedtms.id:9000")
                        .credentials("i9ZB0sNhHaiQe7oEP0sL", "4bxVnKwKgkXpZJ9Dou4oprZ1E8oe3s1HuvKLRn0N")
                        .build();

        String uniqueName = "1693968324774app_ico.png";
        String uniqueApkName = "1693223977836Facebook Lite_368.0.0.5.95_Apkpure.apk";

        String url
                = minioClient.getPresignedObjectUrl(
                        GetPresignedObjectUrlArgs.builder()
                                .method(Method.GET)
                                .bucket("application-bucket")
                                .object("icons/" + uniqueName)
                                .expiry(1, TimeUnit.MINUTES)
                                .build());
        System.out.println("URL: " + url);
        
        String apkUrl
                = minioClient.getPresignedObjectUrl(
                        GetPresignedObjectUrlArgs.builder()
                                .method(Method.GET)
                                .bucket("application-bucket")
                                .object("apps/" + uniqueApkName)
                                .expiry(1, TimeUnit.MINUTES)
                                .build());
        System.out.println("APK URL: " + apkUrl);
        
        System.exit(0);
    }

}
