API Website File Uploader - Panduan Penggunaan
Dokumentasi Api
PHP (cURL)
$file1,
'files[]' => $file2,
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://file.api.akuari.my.id/multi-upload",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
JavaScript (Fetch API)
const formData = new FormData();
formData.append("files", document.querySelector('input[type="file"]').files[0]);
formData.append("files", document.querySelector('input[type="file"]').files[1]);
fetch('https://file.api.akuari.my.id/multi-upload', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Java (HttpURLConnection)
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public class FileUploader {
public static void main(String[] args) throws IOException {
String targetUrl = "https://file.api.akuari.my.id/multi-upload";
String boundary = "===" + System.currentTimeMillis() + "===";
String lineEnd = "\r\n";
File file = new File("path/to/file1.jpg");
HttpURLConnection connection = (HttpURLConnection) new URL(targetUrl).openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes("--" + boundary + lineEnd);
outputStream.writeBytes("Content-Disposition: form-data; name=\"files\"; filename=\"" + file.getName() + "\"" + lineEnd);
outputStream.writeBytes("Content-Type: " + HttpURLConnection.guessContentTypeFromName(file.getName()) + lineEnd);
outputStream.writeBytes(lineEnd);
FileInputStream fileInputStream = new FileInputStream(file);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
fileInputStream.close();
outputStream.writeBytes(lineEnd);
outputStream.writeBytes("--" + boundary + "--" + lineEnd);
outputStream.flush();
outputStream.close();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
connection.disconnect();
}
}
Python (requests)
import requests
url = "https://file.api.akuari.my.id/multi-upload"
files = [
('files', open('path/to/file1.jpg', 'rb')),
('files', open('path/to/file2.jpg', 'rb')),
]
response = requests.post(url, files=files)
print(response.json())