MCPcopy Index your code
hub / github.com/cloudfoundry/cli / CalculateRequestSize

Function CalculateRequestSize

api/cloudcontroller/uploads/upload.go:12–29  ·  view source on GitHub ↗
(fileSize int64, path string, fieldName string)

Source from the content-addressed store, hash-verified

10)
11
12func CalculateRequestSize(fileSize int64, path string, fieldName string) (int64, error) {
13 body := &bytes.Buffer{}
14 form := multipart.NewWriter(body)
15
16 bpFileName := filepath.Base(path)
17
18 _, err := form.CreateFormFile(fieldName, bpFileName)
19 if err != nil {
20 return 0, err
21 }
22
23 err = form.Close()
24 if err != nil {
25 return 0, err
26 }
27
28 return int64(body.Len()) + fileSize, nil
29}
30
31func CreateMultipartBodyAndHeader(file io.Reader, path string, fieldName string) (string, io.ReadSeeker, <-chan error) {
32 writerOutput, writerInput := cloudcontroller.NewPipeBomb()

Callers 2

UploadBuildpackMethod · 0.92
UploadDropletBitsMethod · 0.92

Calls 2

CloseMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected