Skip to main content

file.upload

Upload file content to the OSAPI Object Store. Returns the object name that can be referenced in subsequent file.deploy.execute operations.

Usage

task := plan.TaskFunc("upload-config",
func(
ctx context.Context,
c *client.Client,
) (*orchestrator.Result, error) {
resp, err := c.File.Upload(
ctx,
"nginx.conf",
"application/octet-stream",
bytes.NewReader(configBytes),
)
if err != nil {
return nil, err
}

return &orchestrator.Result{
Changed: true,
Data: orchestrator.StructToMap(resp.Data),
}, nil
},
)

Parameters

ParamTypeRequiredDescription
namestringYesObject name in the Object Store
content_typestringYesMIME type of the content
contentio.ReaderYesFile content to upload

Target

Not applicable. Upload is a server-side operation that does not target an agent.

Idempotency

Idempotent. Uploading the same content with the same name overwrites the existing object.

Permissions

Requires file:write permission.

Example

See examples/sdk/orchestrator/operations/file-upload.go for a complete working example.