Для этого мне нужно использовать решение на основе C++. Я использую подход ниже.
Код: Выделить всё
constexpr std::size_t chunk_size = 1024 * 1024; // 1 MB chunk size
// Function to read a chunk of data from a file
std::vector readChunk(std::ifstream& file, size_t chunkSize) {
std::vector buffer(chunkSize);
file.read(buffer.data(), chunkSize);
buffer.resize(file.gcount());
return buffer;
}
// Function to send a chunk of data
void send_chunk(tcp::socket& socket, const std::vector& chunk, std::size_t total_size) {
http::response res;
res.result(http::status::ok);
res.set(http::field::content_type, "application/octet-stream");
res.set(http::field::content_length, std::to_string(total_size));
res.body() = std::string(chunk.data(), chunk.size());
res.prepare_payload();
res.set(http::field::content_length, std::to_string(total_size));}
// Function to send the file in chunks
void send_file_in_chunks(tcp::socket& socket, const std::string& filename, std::size_t file_size) {
std::ifstream file(filename, std::ios::binary);
if (!file.is_open()) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/78296106/sending-gz-file-in-http-get-response[/url]