cURL
{ printf '%s' $'-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename="example-file"\r\n\r\n'; cat -- example-file; printf '%s' $'\r\n-----011000010111000001101001--'; } | curl --request POST \
--url https://pinapi.jackalprotocol.com/api/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form; boundary=---011000010111000001101001' \
--data-binary @-import requests
url = "https://pinapi.jackalprotocol.com/api/files"
payload = b"".join([
"-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n".encode(),
open("example-file", "rb").read(),
"\r\n-----011000010111000001101001--".encode(),
])
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "multipart/form; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const fileFor = (name) => {
const input = document.querySelector(`input[type="file"][data-name="${CSS.escape(name)}"]`);
if (!input?.files?.[0]) throw new Error(`Select a file for ${name}`);
return input.files[0];
};
const framedBody = new Blob([
"-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n",
fileFor("example-file"),
"\r\n-----011000010111000001101001--",
]);
const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'multipart/form; boundary=---011000010111000001101001'
},
body: framedBody
};
fetch('https://pinapi.jackalprotocol.com/api/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
$file1 = file_get_contents("example-file");
if ($file1 === false) { throw new RuntimeException("unable to read example-file"); }
$payload = "-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n" . $file1 . "\r\n-----011000010111000001101001--";
curl_setopt_array($curl, [
CURLOPT_URL => "https://pinapi.jackalprotocol.com/api/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"bytes"
"fmt"
"net/http"
"io"
"os"
)
func main() {
url := "https://pinapi.jackalprotocol.com/api/files"
var payload bytes.Buffer
payload.WriteString("-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n")
file0, err := os.ReadFile("example-file")
if err != nil {
panic(err)
}
payload.Write(file0)
payload.WriteString("\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, &payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}java.io.ByteArrayOutputStream payload = new java.io.ByteArrayOutputStream();
byte[] part0 = "-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n".getBytes(java.nio.charset.StandardCharsets.UTF_8);
payload.write(part0, 0, part0.length);
byte[] part1 = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get("example-file"));
payload.write(part1, 0, part1.length);
byte[] part2 = "\r\n-----011000010111000001101001--".getBytes(java.nio.charset.StandardCharsets.UTF_8);
payload.write(part2, 0, part2.length);
HttpResponse<String> response = Unirest.post("https://pinapi.jackalprotocol.com/api/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form; boundary=---011000010111000001101001")
.body(payload.toByteArray())
.asString();require 'uri'
require 'net/http'
url = URI("https://pinapi.jackalprotocol.com/api/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'multipart/form; boundary=---011000010111000001101001'
request.body = [
"-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n",
File.binread("example-file"),
"\r\n-----011000010111000001101001--",
].map(&:b).join
response = http.request(request)
puts response.read_bodyfiles
Upload a file
Upload a file
POST
/
files
cURL
{ printf '%s' $'-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename="example-file"\r\n\r\n'; cat -- example-file; printf '%s' $'\r\n-----011000010111000001101001--'; } | curl --request POST \
--url https://pinapi.jackalprotocol.com/api/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form; boundary=---011000010111000001101001' \
--data-binary @-import requests
url = "https://pinapi.jackalprotocol.com/api/files"
payload = b"".join([
"-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n".encode(),
open("example-file", "rb").read(),
"\r\n-----011000010111000001101001--".encode(),
])
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "multipart/form; boundary=---011000010111000001101001"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const fileFor = (name) => {
const input = document.querySelector(`input[type="file"][data-name="${CSS.escape(name)}"]`);
if (!input?.files?.[0]) throw new Error(`Select a file for ${name}`);
return input.files[0];
};
const framedBody = new Blob([
"-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n",
fileFor("example-file"),
"\r\n-----011000010111000001101001--",
]);
const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'multipart/form; boundary=---011000010111000001101001'
},
body: framedBody
};
fetch('https://pinapi.jackalprotocol.com/api/files', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
$file1 = file_get_contents("example-file");
if ($file1 === false) { throw new RuntimeException("unable to read example-file"); }
$payload = "-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n" . $file1 . "\r\n-----011000010111000001101001--";
curl_setopt_array($curl, [
CURLOPT_URL => "https://pinapi.jackalprotocol.com/api/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"bytes"
"fmt"
"net/http"
"io"
"os"
)
func main() {
url := "https://pinapi.jackalprotocol.com/api/files"
var payload bytes.Buffer
payload.WriteString("-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n")
file0, err := os.ReadFile("example-file")
if err != nil {
panic(err)
}
payload.Write(file0)
payload.WriteString("\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, &payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}java.io.ByteArrayOutputStream payload = new java.io.ByteArrayOutputStream();
byte[] part0 = "-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n".getBytes(java.nio.charset.StandardCharsets.UTF_8);
payload.write(part0, 0, part0.length);
byte[] part1 = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get("example-file"));
payload.write(part1, 0, part1.length);
byte[] part2 = "\r\n-----011000010111000001101001--".getBytes(java.nio.charset.StandardCharsets.UTF_8);
payload.write(part2, 0, part2.length);
HttpResponse<String> response = Unirest.post("https://pinapi.jackalprotocol.com/api/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form; boundary=---011000010111000001101001")
.body(payload.toByteArray())
.asString();require 'uri'
require 'net/http'
url = URI("https://pinapi.jackalprotocol.com/api/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'multipart/form; boundary=---011000010111000001101001'
request.body = [
"-----011000010111000001101001\r\nContent-Type: application/octet-stream\r\nContent-Disposition: attachment; filename=\"example-file\"\r\n\r\n",
File.binread("example-file"),
"\r\n-----011000010111000001101001--",
].map(&:b).join
response = http.request(request)
puts response.read_body