Files
核心功能
使用 bucket 组织文件,并通过简单的 HTTP endpoint 访问它们。
Bucket API
创建、列出、读取和删除带名称与描述的 bucket。
文件操作
在 bucket 中上传、下载、列出、查看和删除文件。
存储的元数据
API 会返回大小、MIME 类型、时间戳和内容哈希。
Quick start
快速开始
使用 API 在几秒内开始使用 Files。
curl -X POST https://files.hola.cloud/v1/buckets \
-H 'X-Glue-Authentication: {"user":{"id":"user-123"}}' \
-d '{"name":"my-bucket","description":"Uploads for my app"}'POST /v1/buckets HTTP/1.1
Host: files.hola.cloud
X-Glue-Authentication: {"user":{"id":"user-123"}}
{"name":"my-bucket","description":"Uploads for my app"}// Go 1.21+, standard library only. Save as main.go and run: go run main.go
package main
import (
"fmt"
"io"
"net/http"
"encoding/json"
"strings"
)
func main() {
payload := map[string]any{"description": "Uploads for my app", "name": "my-bucket"}
bodyBytes, err := json.Marshal(payload)
if err != nil {
panic(err)
}
body := string(bodyBytes)
req, err := http.NewRequest("POST", "https://files.hola.cloud/v1/buckets", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("X-Glue-Authentication", "{\"user\":{\"id\":\"user-123\"}}")
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(resp.Status)
fmt.Println(string(responseBody))
}
<?php
// PHP 8+ with the curl extension. Save as example.php and run: php example.php
$payload = ['description' => 'Uploads for my app', 'name' => 'my-bucket'];
$body = json_encode($payload);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://files.hola.cloud/v1/buckets',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => [
'X-Glue-Authentication: {"user":{"id":"user-123"}}',
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n", $response, "\n";
curl_close($ch);
# Python 3.8+. Install: pip install requests. Save as example.py and run: python example.py
import requests
headers = {
"X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}",
}
payload = {"description": "Uploads for my app", "name": "my-bucket"}
response = requests.request(
"POST",
"https://files.hola.cloud/v1/buckets",
headers=headers,
json=payload
)
print(response.status_code)
print(response.text)
// Node.js 18+. Save as example.mjs and run: node example.mjs
const payload = {"description": "Uploads for my app", "name": "my-bucket"};
const response = await fetch("https://files.hola.cloud/v1/buckets", {
method: "POST",
headers: {
"X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}"
},
body: JSON.stringify(payload)
});
console.log(response.status);
console.log(await response.text());
const payload = {"description": "Uploads for my app", "name": "my-bucket"};
const response = await fetch("https://files.hola.cloud/v1/buckets", {
method: "POST",
headers: {
"X-Glue-Authentication": "{\"user\":{\"id\":\"user-123\"}}"
},
body: JSON.stringify(payload)
});
console.log(response.status);
console.log(await response.text());
// Java 17+, standard library only. Save as Main.java and run: java Main.java
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 = """
{"name":"my-bucket","description":"Uploads for my app"}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://files.hola.cloud/v1/buckets"))
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.header("X-Glue-Authentication", "{\"user\":{\"id\":\"user-123\"}}")
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}Use cases
常见用例
微服务编排
Build and deploy with Files on HolaCloud's enterprise platform, designed for security, reliability, and scale.
数据管道自动化
Build and deploy with Files on HolaCloud's enterprise platform, designed for security, reliability, and scale.
事件驱动架构
Build and deploy with Files on HolaCloud's enterprise platform, designed for security, reliability, and scale.
后端 API 开发
Build and deploy with Files on HolaCloud's enterprise platform, designed for security, reliability, and scale.
评论