MCPcopy Create free account
hub / github.com/cloudfoundry/multiapps-cli-plugin / uploadFilePart

Method uploadFilePart

commands/file_uploader.go:238–251  ·  view source on GitHub ↗
(filePart *os.File, fileName string, pb *pb.ProgressBar)

Source from the content-addressed store, hash-verified

236}
237
238func (f *FileUploader) uploadFilePart(filePart *os.File, fileName string, pb *pb.ProgressBar) (*models.FileMetadata, error) {
239 defer filePart.Close()
240 fileInfo, err := filePart.Stat()
241 if err != nil {
242 return nil, fmt.Errorf("could not stat file part %q of file %q", filePart.Name(), fileName)
243 }
244
245 file := &progressBarReader{file: filePart, fileName: fileInfo.Name(), pb: pb}
246 uploadedFile, err := f.mtaClient.UploadMtaFile(file, fileInfo.Size(), &f.namespace)
247 if err != nil {
248 return nil, fmt.Errorf("could not upload file %s: %s", terminal.EntityNameColor(fileName), err)
249 }
250 return uploadedFile, nil
251}
252
253func (f *FileUploader) isFileAlreadyUploaded(newFilePath string, fileInfo os.FileInfo, oldFiles []*models.FileMetadata, alreadyUploadedFiles *[]*models.FileMetadata) bool {
254 for _, oldFile := range oldFiles {

Callers 1

uploadInChunksMethod · 0.95

Calls 5

StatMethod · 0.80
SizeMethod · 0.80
NameMethod · 0.65
UploadMtaFileMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected