Subir Archivo
Sube un archivo a un bucket. La ruta del archivo va después de /files/.
Autenticación
Requiere X-Glue-Authentication.
Solicitud
curl -X PUT "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png" \
-H 'X-Glue-Authentication: {"user":{"id":"user-123"}}' \
-H "Content-Type: image/png" \
--data-binary @logo.pngPUT /v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png HTTP/1.1
Host: api.hola.cloud
X-Glue-Authentication: {"user":{"id":"user-123"}}
Content-Type: image/png
@logo.pngpackage main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := "@logo.png"
req, err := http.NewRequest("PUT", "https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("X-Glue-Authentication", "{\"user\":{\"id\":\"user-123\"}}")
req.Header.Set("Content-Type", "image/png")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(responseBody))
}
<?php
$body = '@logo.png';
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => [
'X-Glue-Authentication: {"user":{"id":"user-123"}}',
'Content-Type: image/png',
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
echo $response;
import requests
headers = {
"X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}",
"Content-Type": "image/png",
}
body = "@logo.png"
response = requests.request(
"PUT",
"https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png",
headers=headers,
data=body
)
print(response.text)
const body = "@logo.png";
const response = await fetch("https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png", {
method: "PUT",
headers: {
"X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}",
"Content-Type": "image/png"
},
body
});
console.log(await response.text());
const body = "@logo.png";
const response = await fetch("https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png", {
method: "PUT",
headers: {
"X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}",
"Content-Type": "image/png"
},
body
});
const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
var body = """
@logo.png
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.hola.cloud/v1/buckets/bucket-550e8400-e29b-41d4-a716-446655440000/files/images/logo.png"))
.method("PUT", HttpRequest.BodyPublishers.ofString(body))
.header("X-Glue-Authentication", "{\"user\":{\"id\":\"user-123\"}}")
.header("Content-Type", "image/png")
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}Respuesta
Devuelve un objeto file con id, uuid, created_timestamp, updated_timestamp, owners, status, size, name, bucket, hash_md5, hash_sha256 y mime_type.
Comentarios