本文整理汇总了Golang中github.com/pachyderm/pachyderm/src/pfs.PutFileRequest类的典型用法代码示例。如果您正苦于以下问题:Golang PutFileRequest类的具体用法?Golang PutFileRequest怎么用?Golang PutFileRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PutFileRequest类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: PutFile
func PutFile(apiClient pfs.ApiClient, repoName string, commitID string, path string, offset int64, reader io.Reader) (_ int, retErr error) {
putFileClient, err := apiClient.PutFile(context.Background())
if err != nil {
return 0, err
}
defer func() {
if _, err := putFileClient.CloseAndRecv(); err != nil && retErr != nil {
retErr = err
}
}()
request := pfs.PutFileRequest{
File: &pfs.File{
Commit: &pfs.Commit{
Repo: &pfs.Repo{
Name: repoName,
},
Id: commitID,
},
Path: path,
},
FileType: pfs.FileType_FILE_TYPE_REGULAR,
OffsetBytes: offset,
}
var size int
for {
value := make([]byte, chunkSize)
iSize, err := reader.Read(value)
request.Value = value[0:iSize]
if err != nil {
if err == io.EOF {
break
}
return 0, err
}
size += iSize
protolog.Printf("pfsutil.PutFile Send(%+v)", request)
if err := putFileClient.Send(&request); err != nil {
return 0, err
}
}
if err != nil && err != io.EOF {
return 0, err
}
return size, err
}
开发者ID:sr,项目名称:pachyderm,代码行数:45,代码来源:pfsutil.go
示例2: PutFile
func PutFile(apiClient pfs.APIClient, repoName string, commitID string, path string, offset int64, reader io.Reader) (_ int, retErr error) {
putFileClient, err := apiClient.PutFile(context.Background())
if err != nil {
return 0, err
}
defer func() {
if _, err := putFileClient.CloseAndRecv(); err != nil && retErr == nil {
retErr = err
}
}()
request := pfs.PutFileRequest{
File: NewFile(repoName, commitID, path),
FileType: pfs.FileType_FILE_TYPE_REGULAR,
OffsetBytes: offset,
}
var size int
eof := false
for !eof {
value := make([]byte, chunkSize)
iSize, err := reader.Read(value)
if err != nil && err != io.EOF {
return 0, err
}
if err == io.EOF {
eof = true
}
request.Value = value[0:iSize]
size += iSize
if err := putFileClient.Send(&request); err != nil {
return 0, err
}
}
if err != nil && err != io.EOF {
return 0, err
}
return size, err
}
开发者ID:tv42,项目名称:pachyderm,代码行数:37,代码来源:pfsutil.go
注:本文中的github.com/pachyderm/pachyderm/src/pfs.PutFileRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论