mirror of https://github.com/databricks/cli.git
simplify copy
This commit is contained in:
parent
9552131a2a
commit
7ab9fb7cec
|
@ -167,18 +167,7 @@ func (w *DbfsClient) putFile(ctx context.Context, path string, overwrite bool, f
|
||||||
pw.CloseWithError(fmt.Errorf("failed to write contents field in multipart form: %w", err))
|
pw.CloseWithError(fmt.Errorf("failed to write contents field in multipart form: %w", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for {
|
_, err = io.Copy(contents, file)
|
||||||
// Copy the file in 10 MB chunks. This reduces the memory usage of the
|
|
||||||
// program when copying large files.
|
|
||||||
_, err := io.CopyN(contents, file, 10*1024*1024)
|
|
||||||
if err == io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
pw.CloseWithError(fmt.Errorf("failed to copy file in multipart form: %w", err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = writer.Close()
|
err = writer.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pw.CloseWithError(fmt.Errorf("failed to close multipart form writer: %w", err))
|
pw.CloseWithError(fmt.Errorf("failed to close multipart form writer: %w", err))
|
||||||
|
|
Loading…
Reference in New Issue