本文整理汇总了Golang中github.com/juju/juju/state/backups.Backups类的典型用法代码示例。如果您正苦于以下问题:Golang Backups类的具体用法?Golang Backups怎么用?Golang Backups使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Backups类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: upload
func (h *backupHandler) upload(backups backups.Backups, resp http.ResponseWriter, req *http.Request) (string, error) {
// Since we want to stream the archive in we cannot simply use
// mime/multipart directly.
defer req.Body.Close()
var metaResult params.BackupsMetadataResult
archive, err := httpattachment.Get(req, &metaResult)
if err != nil {
return "", err
}
if err := validateBackupMetadataResult(metaResult); err != nil {
return "", err
}
meta := apiserverbackups.MetadataFromResult(metaResult)
id, err := backups.Add(archive, meta)
if err != nil {
return "", err
}
if err := sendStatusAndJSON(resp, http.StatusOK, ¶ms.BackupsUploadResult{ID: id}); err != nil {
return "", errors.Trace(err)
}
return id, nil
}
示例2: download
func (h *backupHandler) download(backups backups.Backups, resp http.ResponseWriter, req *http.Request) (string, error) {
args, err := h.parseGETArgs(req)
if err != nil {
return "", err
}
logger.Infof("backups download request for %q", args.ID)
meta, archive, err := backups.Get(args.ID)
if err != nil {
return "", err
}
defer archive.Close()
err = h.sendFile(archive, meta.Checksum(), resp)
return args.ID, err
}