本文整理匯總了Golang中github.com/minio/mc/pkg/client.Client.ShareDownload方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.ShareDownload方法的具體用法?Golang Client.ShareDownload怎麽用?Golang Client.ShareDownload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/minio/mc/pkg/client.Client
的用法示例。
在下文中一共展示了Client.ShareDownload方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doShareDownloadURL
// doShareURL share files from target
func doShareDownloadURL(targetURL string, recursive bool, expires time.Duration) *probe.Error {
shareDate := time.Now().UTC()
sURLs, err := loadSharedURLsV3()
if err != nil {
return err.Trace()
}
var clnt client.Client
clnt, err = url2Client(targetURL)
if err != nil {
return err.Trace()
}
if expires.Seconds() < 1 {
return probe.NewError(errors.New("Too low expires, expiration cannot be less than 1 second."))
}
if expires.Seconds() > 604800 {
return probe.NewError(errors.New("Too high expires, expiration cannot be larger than 7 days."))
}
for contentCh := range clnt.List(recursive, false) {
if contentCh.Err != nil {
return contentCh.Err.Trace()
}
var newClnt client.Client
newClnt, err = url2Client(getNewTargetURL(clnt.URL(), contentCh.Content.Name))
if err != nil {
return err.Trace()
}
var sharedURL string
sharedURL, err = newClnt.ShareDownload(expires)
if err != nil {
return err.Trace()
}
shareMessage := ShareMessage{
Expiry: expires,
DownloadURL: sharedURL,
Key: newClnt.URL().String(),
}
shareMessageV3 := ShareMessageV3{
Expiry: expires,
DownloadURL: sharedURL,
Key: newClnt.URL().String(),
}
sURLs.URLs = append(sURLs.URLs, struct {
Date time.Time
Message ShareMessageV3
}{
Date: shareDate,
Message: shareMessageV3,
})
Prints("%s\n", shareMessage)
}
saveSharedURLsV3(sURLs)
return nil
}