Skip to content
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

S3 upload is failing when data is read from stdin #246

Open
PrasadG193 opened this issue Nov 23, 2020 · 0 comments
Open

S3 upload is failing when data is read from stdin #246

PrasadG193 opened this issue Nov 23, 2020 · 0 comments

Comments

@PrasadG193
Copy link

PrasadG193 commented Nov 23, 2020

I am trying to upload the output of a command using a pipe, while doing so, Put() fails with the following error.

2020/11/23 13:43:37 PutObject, putting object: ReadRequestBody: unable to initialize upload
caused by: seek /dev/stdin: illegal seek

This is the sample code for repro:

package main

import (
        "log"
        "os"

        "github.com/graymeta/stow"
        _ "github.com/graymeta/stow/s3"
)

func main() {
        accessKeyId := os.Getenv("S3ACCESSKEYID")
        secretKey := os.Getenv("S3SECRETKEY")
        region := os.Getenv("S3REGION")
        bucket := os.Getenv("S3BUCKET")

        if accessKeyId == "" || secretKey == "" || region == "" || bucket == "" {
                log.Println("skipping test because missing one or more of S3ACCESSKEYID S3SECRETKEY S3REGION S3BUCKET")
                os.Exit(1)
        }

        config := stow.ConfigMap{
                "access_key_id": accessKeyId,
                "secret_key":    secretKey,
                "region":        region,
        }

        location, err := stow.Dial("s3", config)
        if err != nil {
                log.Fatal(err)
        }
        defer location.Close()

        c, err := location.Container(bucket)
        if err != nil {
                log.Fatal(err)
        }

        _, err = c.Put("test-stream", os.Stdin, 0, nil)
        if err != nil {
                log.Fatal(err)
        }
}

Output:

$ echo "sample text" | go run main.go 
2020/11/23 13:43:37 PutObject, putting object: ReadRequestBody: unable to initialize upload
caused by: seek /dev/stdin: illegal seek
exit status 1
@PrasadG193 PrasadG193 changed the title S3 upload is failing when data is read from pipe S3 upload is failing when data is read from stdin Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant