create_policy
POST
/api/v1/admin/policies
const url = 'https://example.com/api/v1/admin/policies';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"access_key":"example","allowed_types":["example"],"application_config":{"microsoft_graph":{"client_id":"example","client_secret":"example","cloud":"global","scopes":["example"],"tenant":"example"}},"base_path":"example","bucket":"example","chunk_size":1,"driver_type":"local","endpoint":"example","is_default":true,"max_file_size":1,"name":"example","options":{"content_dedup":true,"media_metadata_extensions":["example"],"object_storage_download_strategy":"relay_stream","object_storage_upload_strategy":"relay_stream","onedrive_account_mode":"personal","onedrive_cloud":"global","onedrive_drive_id":"example","onedrive_group_id":"example","onedrive_root_item_id":"example","onedrive_site_id":"example","onedrive_tenant":"example","provider_download_filename_mode":"provider_native","provider_download_strategy":"server_relay","provider_resumable_upload_strategy":"server_relay","remote_download_strategy":"relay_stream","remote_upload_strategy":"relay_stream","s3_connect_timeout_secs":1,"s3_operation_timeout_secs":1,"s3_path_style":true,"s3_read_timeout_secs":1,"sftp_host_key_fingerprint":"example","storage_native_media_metadata_enabled":true,"storage_native_processing_enabled":true,"thumbnail_extensions":["example"],"thumbnail_processor":"images"},"remote_node_id":1,"remote_storage_target_key":"example","secret_key":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://example.com/api/v1/admin/policies";
let payload = json!({ "access_key": "example", "allowed_types": ("example"), "application_config": json!({"microsoft_graph": json!({ "client_id": "example", "client_secret": "example", "cloud": "global", "scopes": ("example"), "tenant": "example" })}), "base_path": "example", "bucket": "example", "chunk_size": 1, "driver_type": "local", "endpoint": "example", "is_default": true, "max_file_size": 1, "name": "example", "options": json!({ "content_dedup": true, "media_metadata_extensions": ("example"), "object_storage_download_strategy": "relay_stream", "object_storage_upload_strategy": "relay_stream", "onedrive_account_mode": "personal", "onedrive_cloud": "global", "onedrive_drive_id": "example", "onedrive_group_id": "example", "onedrive_root_item_id": "example", "onedrive_site_id": "example", "onedrive_tenant": "example", "provider_download_filename_mode": "provider_native", "provider_download_strategy": "server_relay", "provider_resumable_upload_strategy": "server_relay", "remote_download_strategy": "relay_stream", "remote_upload_strategy": "relay_stream", "s3_connect_timeout_secs": 1, "s3_operation_timeout_secs": 1, "s3_path_style": true, "s3_read_timeout_secs": 1, "sftp_host_key_fingerprint": "example", "storage_native_media_metadata_enabled": true, "storage_native_processing_enabled": true, "thumbnail_extensions": ("example"), "thumbnail_processor": "images" }), "remote_node_id": 1, "remote_storage_target_key": "example", "secret_key": "example" });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://example.com/api/v1/admin/policies \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "access_key": "example", "allowed_types": [ "example" ], "application_config": { "microsoft_graph": { "client_id": "example", "client_secret": "example", "cloud": "global", "scopes": [ "example" ], "tenant": "example" } }, "base_path": "example", "bucket": "example", "chunk_size": 1, "driver_type": "local", "endpoint": "example", "is_default": true, "max_file_size": 1, "name": "example", "options": { "content_dedup": true, "media_metadata_extensions": [ "example" ], "object_storage_download_strategy": "relay_stream", "object_storage_upload_strategy": "relay_stream", "onedrive_account_mode": "personal", "onedrive_cloud": "global", "onedrive_drive_id": "example", "onedrive_group_id": "example", "onedrive_root_item_id": "example", "onedrive_site_id": "example", "onedrive_tenant": "example", "provider_download_filename_mode": "provider_native", "provider_download_strategy": "server_relay", "provider_resumable_upload_strategy": "server_relay", "remote_download_strategy": "relay_stream", "remote_upload_strategy": "relay_stream", "s3_connect_timeout_secs": 1, "s3_operation_timeout_secs": 1, "s3_path_style": true, "s3_read_timeout_secs": 1, "sftp_host_key_fingerprint": "example", "storage_native_media_metadata_enabled": true, "storage_native_processing_enabled": true, "thumbnail_extensions": [ "example" ], "thumbnail_processor": "images" }, "remote_node_id": 1, "remote_storage_target_key": "example", "secret_key": "example" }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
Create a storage policy.
object
access_key
string | null
allowed_types
Array<string> | null
application_config
base_path
string | null
bucket
string | null
chunk_size
integer | null format: int64
driver_type
required
存储驱动类型
string
endpoint
string | null
is_default
boolean | null
max_file_size
integer | null format: int64
name
required
string
options
One of:
null
object
content_dedup
boolean | null
media_metadata_extensions
Array<string>
object_storage_download_strategy
onedrive_account_mode
onedrive_cloud
onedrive_drive_id
string | null
onedrive_group_id
string | null
onedrive_root_item_id
string | null
onedrive_site_id
string | null
onedrive_tenant
string | null
provider_download_filename_mode
provider_resumable_upload_strategy
s3_connect_timeout_secs
integer | null format: int64
s3_operation_timeout_secs
integer | null format: int64
s3_path_style
boolean | null
s3_read_timeout_secs
integer | null format: int64
sftp_host_key_fingerprint
string | null
storage_native_media_metadata_enabled
boolean | null
storage_native_processing_enabled
boolean | null
thumbnail_extensions
Array<string>
remote_node_id
integer | null format: int64
remote_storage_target_key
string | null
secret_key
string | null
Responses
Section titled “Responses”Policy created
Media typeapplication/json
统一 API 响应格式
成功: { "code": "success", "msg": "", "data": {...} }
失败: { "code": "auth.credentials_failed", "msg": "Invalid Credentials" }
object
code
required
string
data
object
allowed_types
required
Array<string>
base_path
required
string
bucket
required
string
chunk_size
required
integer format: int64
created_at
required
string
driver_type
required
存储驱动类型
string
endpoint
required
string
id
required
integer format: int64
is_default
required
boolean
max_file_size
required
integer format: int64
name
required
string
options
required
object
content_dedup
boolean | null
media_metadata_extensions
Array<string>
object_storage_download_strategy
onedrive_account_mode
onedrive_cloud
onedrive_drive_id
string | null
onedrive_group_id
string | null
onedrive_root_item_id
string | null
onedrive_site_id
string | null
onedrive_tenant
string | null
provider_download_filename_mode
provider_resumable_upload_strategy
s3_connect_timeout_secs
integer | null format: int64
s3_operation_timeout_secs
integer | null format: int64
s3_path_style
boolean | null
s3_read_timeout_secs
integer | null format: int64
sftp_host_key_fingerprint
string | null
storage_native_media_metadata_enabled
boolean | null
storage_native_processing_enabled
boolean | null
thumbnail_extensions
Array<string>
remote_node_id
integer | null format: int64
remote_storage_target_key
string | null
updated_at
required
string
error
msg
required
string
Example
{ "code": "success", "data": { "driver_type": "local", "options": { "object_storage_download_strategy": "relay_stream", "object_storage_upload_strategy": "relay_stream", "onedrive_account_mode": "personal", "onedrive_cloud": "global", "provider_download_filename_mode": "provider_native", "provider_download_strategy": "server_relay", "provider_resumable_upload_strategy": "server_relay", "remote_download_strategy": "relay_stream", "remote_upload_strategy": "relay_stream", "thumbnail_processor": "images" } }}Unauthorized
Forbidden