Upload an image to a planet
Got a crazy good photo of a planet? Share it with the world!
AuthorizationBearer <token>
JWT Bearer token authentication
In: header
Path Parameters
planetIdinteger
The ID of the planet to get
Format
int64
Image to upload
image?file
The image file to upload
Format
binary
Response Body
curl -X POST "https://galaxy.scalar.com/planets/1/image"
const body = new FormData();
fetch("https://galaxy.scalar.com/planets/1/image", {
body
})
package main
import (
"fmt"
"net/http"
"io/ioutil"
"mime/multipart"
"bytes"
)
func main() {
url := "https://galaxy.scalar.com/planets/1/image"
body := new(bytes.Buffer)
mp := multipart.NewWriter(payload)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Content-Type", "multipart/form-data")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import requests
url = "https://galaxy.scalar.com/planets/1/image"
body = {}
response = requests.request("POST", url, data = body, headers = {
"Content-Type": "multipart/form-data"
})
print(response.text)
{
"message": "Image uploaded successfully",
"imageUrl": "https://cdn.scalar.com/images/8f47c132-9d1f-4f83-b5a4-91db5ee757ab.jpg",
"uploadedAt": "2024-01-15T14:30:00Z",
"fileSize": 1048576,
"mimeType": "image/jpeg"
}
{
"type": "https://example.com/errors/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "The request was invalid."
}
{
"type": "https://example.com/errors/forbidden",
"title": "Forbidden",
"status": 403,
"detail": "You are not authorized to access this resource."
}
{
"type": "https://example.com/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "The resource you are trying to access does not exist."
}
How is this guide?