From 4f9a1a11d657c70c1f8b520cfd4e5e8656f71ccf Mon Sep 17 00:00:00 2001 From: Alex Shcherbakov Date: Tue, 16 Apr 2024 12:15:04 +0300 Subject: [PATCH] hotfix: Provide content length on file put (#217) Closes https://github.com/databricks/databricks-sql-go/issues/211 Instead of https://github.com/databricks/databricks-sql-go/pull/212 Signed-off-by: candiduslynx --- connection.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/connection.go b/connection.go index 6464a56..857f9f0 100644 --- a/connection.go +++ b/connection.go @@ -438,7 +438,13 @@ func (c *conn) handleStagingPut(ctx context.Context, presignedUrl string, header } defer dat.Close() + info, err := dat.Stat() + if err != nil { + return dbsqlerrint.NewDriverError(ctx, "error reading local file info", err) + } + req, _ := http.NewRequest("PUT", presignedUrl, dat) + req.ContentLength = info.Size() // backend actually requires content length to be known for k, v := range headers { req.Header.Set(k, v)