package cn.iocoder.yudao.module.llm.utils;

import org.springframework.stereotype.Component;

import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;

@Component
public class DataSetReadFileUtils {
    public static HttpURLConnection readFile(String filePath) {
        try {
            URL url = new URL(filePath);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");

            if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
                return connection;
            } else {
                System.out.println("Failed to fetch file. Server returned HTTP code: " + connection.getResponseCode());
            }
            connection.disconnect();
        } catch (Exception e) {
            System.out.println("Error fetching file from URL: " + e.getMessage());
        }
        return null;
    }
}
