mirror of git3://git3.w3q/git3-cli
parent
453b37fcc8
commit
547746302e
@ -1,26 +0,0 @@
|
||||
import axios from "axios"
|
||||
import FormData from "form-data"
|
||||
|
||||
async function main() {
|
||||
let auth =
|
||||
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweGFEQTdCOWFlQTdGNTc2ZDI5NzM0ZWUxY0Q2ODVFMzc2OWNCM2QwRDEiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY3NTQ5NDYwMDkzMiwibmFtZSI6ImZ2bS1oYWNrc29uIn0.YBqfsj_LTZSJPKc0OH586avnQNqove_Htzl5rrToXTk"
|
||||
|
||||
let data = new FormData()
|
||||
data.append("file", Buffer.from("hello world1"), {
|
||||
filename: "hello.txt",
|
||||
})
|
||||
|
||||
data.append("file", Buffer.from("hello world2"), {
|
||||
filename: "hello.txt",
|
||||
})
|
||||
|
||||
let response = await axios.post("https://api.nft.storage/upload", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
Authorization: auth,
|
||||
},
|
||||
})
|
||||
console.log(response.status, JSON.stringify(response.data))
|
||||
}
|
||||
|
||||
main()
|
@ -1,23 +0,0 @@
|
||||
import axios from "axios"
|
||||
import Form from "form-data"
|
||||
let form = new Form()
|
||||
|
||||
form.append("file", Buffer.from("hello world"), {
|
||||
filename: "",
|
||||
contentType: "image/*",
|
||||
})
|
||||
const response = await axios.post(
|
||||
"https://api.nft.storage/upload",
|
||||
Buffer.from("hello world"),
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/octet-stream",
|
||||
Authorization:
|
||||
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkaWQ6ZXRocjoweGFEQTdCOWFlQTdGNTc2ZDI5NzM0ZWUxY0Q2ODVFMzc2OWNCM2QwRDEiLCJpc3MiOiJuZnQtc3RvcmFnZSIsImlhdCI6MTY3NTQ5NDYwMDkzMiwibmFtZSI6ImZ2bS1oYWNrc29uIn0.YBqfsj_LTZSJPKc0OH586avnQNqove_Htzl5rrToXTk",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
console.log(response.status)
|
||||
console.log(response.headers)
|
||||
console.log(response.data)
|
Loading…
Reference in new issue