Java Example
Uploads a file to owf.gay in one request via POST /a/1/u/s, using Java's standard HTTP client - no third-party library required.
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;
import java.io.ByteArrayOutputStream;
public class Upload {
public static void main(String[] args) throws Exception {
String boundary = "----owfgayBoundary";
Path file = Path.of("file.txt");
byte[] fileBytes = Files.readAllBytes(file);
String header = "--" + boundary + "\r\nContent-Disposition: form-data; name=\"f\"; filename=\"" + file.getFileName() + "\"\r\nContent-Type: application/octet-stream\r\n\r\n";
String footer = "\r\n--" + boundary + "--\r\n";
ByteArrayOutputStream body = new ByteArrayOutputStream();
body.write(header.getBytes());
body.write(fileBytes);
body.write(footer.getBytes());
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://owf.gay/a/1/u/s"))
// .header("X-Api-Key", "your-api-key") // if accounts are enabled
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(body.toByteArray()))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body()); // the file's URL
}
}
Full endpoint details are on the API page.