-
Notifications
You must be signed in to change notification settings - Fork 850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convenience layer for uploading file to ADLS #3231
Comments
A quick test of only creating an empty file with
|
I don't think this is specific to the Go SDK as I can repro this same behavior using powershell. @joshgav can you please loop in somebody from the data lake store team to help? |
It would be great if someone could take a look at this? |
@fantyz I'm trying to find somebody from the service team to take a look. |
OK, the issue here is that the service only supports uploads in 4MB chunks. This is documented here however is easy to overlook; see the |
Here's a working example. package main
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"os"
"github.com/Azure/azure-sdk-for-go/services/datalake/store/2016-11-01/filesystem"
"github.com/Azure/go-autorest/autorest/azure/auth"
)
const (
accountName = "<account name>"
destination = "<destination>"
inputFile = `<big file for upload>`
bufferSize = 4 * 1024 * 1024
)
func main() {
a, err := auth.NewAuthorizerFromEnvironment()
if err != nil {
panic(err)
}
client := filesystem.NewClient()
client.Authorizer = a
f, err := os.Open(inputFile)
if err != nil {
panic(err)
}
defer f.Close()
resp, err := client.Create(context.Background(), accountName, destination, nil, nil, filesystem.DATA, nil, nil)
if err != nil {
panic(err)
}
fmt.Println(resp.Status)
buffer := make([]byte, bufferSize, bufferSize)
for {
n, err := f.Read(buffer)
if err == io.EOF {
break
}
flag := filesystem.DATA
if n < bufferSize {
// last chunk
flag = filesystem.CLOSE
}
chunk := ioutil.NopCloser(bytes.NewReader(buffer))
fmt.Printf("uploading chunk %d...", n)
resp, err = client.Append(context.Background(), accountName, destination, chunk, nil, flag, nil, nil)
if err != nil {
panic(err)
}
fmt.Printf("%d\n", resp.StatusCode)
}
fmt.Println("done!")
} |
Opened Azure/azure-rest-api-specs#4464 to update the SDK docs. |
Thanks - we'll do the suggested work-around. I was kinda hoping for such low level code as calls to I would avoid doing the From https://golang.org/pkg/io/#Reader
You also have the case where the last call to |
Sorry I should have prefaced my sample as non-production code. |
Track1 will not provide a GA library with datalake support. |
Hi,
We're having issues uploading files to ADLS using the SDK.
We're using:
github.com/Azure/azure-sdk-for-go/services/datalake/store/2016-11-01/filesystem
(v21.1.0,6d20bdbae88c06c36d72eb512295417693bfdf4e
)github.com/Azure/go-autorest
(v10.15.5,9bc4033dd347c7f416fca46b2f42a043dc1fbdf6
)When doing
client.Create
we get the following error consistently:It only happens with larger files (I do not know what the cut-off point is, but a 500kb file uploads fine and a 37mb file consistently fails.
It would also be great if you could return informative errors instead of this. I mean it might as well have returned a plain: "Some error happened. Too bad."
The text was updated successfully, but these errors were encountered: