我正在尝试将多部分文件上传到 blob AppendBlock(),但出现此错误:
-> github.com/Azure/azure-pipeline-go/pipeline.NewError, /home/makoto/go/pkg/mod/github.com/!azure/azure-pipeline-go@v0.2.1/pipeline/error.go:159
validation failed: parameter=body constraint=Null value=multipart.sectionReadCloser{SectionReader:(*io.SectionReader)(0xc000643a40)} details: field "body" doesn't exist
func Upload(file multipart.File) error {
credential, err := azblob.NewSharedKeyCredential("credential strings", "")
if err != nil {
return err
}
u, _ := url.Parse("blob url")
appendBlobURL := azblob.NewAppendBlobURL(
*u,
azblob.NewPipeline(credential, azblob.PipelineOptions{}),
)
_, err = appendBlobURL.Create(
context.Background(),
azblob.BlobHTTPHeaders{},
azblob.Metadata{},
azblob.BlobAccessConditions{},
)
if err != nil {
return err
}
_, err = appendBlobURL.AppendBlock(context.Background(), file, azblob.AppendBlobAccessConditions{}, nil)
// validation failed: parameter=body constraint=Null value=multipart.sectionReadCloser{SectionReader:(*io.SectionReader)(0xc000643a40)}
// details: field "body" doesn't exist
return err
}
string.Builder如果我传递 a而不是多部分文件,它可以正常工作而不会引发错误。
为什么会出现此错误?我该如何修复它?
吃鸡游戏
青春有我
相关分类