Roe Datasets
Download File
Download a file by its file string identifier.
GET
/
v1
/
datasets
/
files
/
{file_str}
/
download
/
Copy
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string fileId = "YOUR_FILE_ID"; // Replace with your file ID
string token = "YOUR_API_TOKEN"; // Replace with your API token
string outputPath = "downloaded_file.pdf"; // Path where to save the downloaded file
string url = $"https://api.roe-ai.com/v1/datasets/files/{fileId}/download/";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
// Send the request
HttpResponseMessage response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
// For binary files, save the content to a file
byte[] fileBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes(outputPath, fileBytes);
Console.WriteLine($"File downloaded successfully to {outputPath}");
// If you want to read as text instead (for text files)
// string responseBody = await response.Content.ReadAsStringAsync();
// Console.WriteLine(responseBody);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
string errorContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(errorContent);
}
}
}
Copy
"Binary file content"
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Path Parameters
File string identifier (encoded file ID with optional metadata)
Query Parameters
Page range for PDF files (e.g., '1-5', '1,3,5', '1-3,5-7')
Response
200
application/json
File content
The response is of type file
.
Copy
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string fileId = "YOUR_FILE_ID"; // Replace with your file ID
string token = "YOUR_API_TOKEN"; // Replace with your API token
string outputPath = "downloaded_file.pdf"; // Path where to save the downloaded file
string url = $"https://api.roe-ai.com/v1/datasets/files/{fileId}/download/";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
// Send the request
HttpResponseMessage response = await client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
// For binary files, save the content to a file
byte[] fileBytes = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes(outputPath, fileBytes);
Console.WriteLine($"File downloaded successfully to {outputPath}");
// If you want to read as text instead (for text files)
// string responseBody = await response.Content.ReadAsStringAsync();
// Console.WriteLine(responseBody);
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
string errorContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(errorContent);
}
}
}
Copy
"Binary file content"
Assistant
Responses are generated using AI and may contain mistakes.