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

Error uploading path with special characters #741

Closed
minhjh opened this issue Sep 3, 2021 · 8 comments
Closed

Error uploading path with special characters #741

minhjh opened this issue Sep 3, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@minhjh
Copy link

minhjh commented Sep 3, 2021

s, err := s3.NewStorager(
	pairs.WithEndpoint("http:127.0.0.1:9000"),
	pairs.WithCredential("hmac:minio:minio123456"),
	pairs.WithLocation("us-east-1"),
	pairs.WithName("/default"),
	pairs.WithWorkDir("/"),
)

if err != nil {
	fmt.Println(err)
}

f, _ := os.Open("IMG@@@_0960.JPG")
fi, _ := f.Stat()

fmt.Println(s.WriteWithContext(context.Background(), "IMG@@@¥&_0960.JPG", f, fi.Size())) // error
fmt.Println(s.WriteWithContext(context.Background(), "IMG_0960.JPG", f, fi.Size()))      // success
@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 3, 2021

Hello, can you also paste the error response here?

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 3, 2021

Hi, I can't reproduce this error. Here is my test case:

func TestIssue741(t *testing.T) {
	if os.Getenv("STORAGE_S3_INTEGRATION_TEST") != "on" {
		t.Skipf("STORAGE_S3_INTEGRATION_TEST is not 'on', skipped")
	}
	store := setupTest(t)

	content := []byte("Hello, World!")
	r := bytes.NewReader(content)

	_, err := store.Write("IMG@@@¥&_0960.jpg", r, int64(len(content)))
	if err != nil {
		t.Errorf("write: %v", err)
		return
	}
	return
}
:) go test -count=1 ./tests -v -run TestIssue741
=== RUN   TestIssue741
    utils_test.go:15: Setup test for s3
--- PASS: TestIssue741 (0.58s)
PASS
ok      github.com/beyondstorage/go-service-s3/v2/tests 0.584s

image

Test passed with v2.4.0.

@Xuanwo Xuanwo added the bug Something isn't working label Sep 3, 2021
@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 3, 2021

BTW, I found the name you set is /default, and I think it's a invalid bucket name for s3.

@minhjh
Copy link
Author

minhjh commented Sep 4, 2021

BTW, I found the name you set is /default, and I think it's a invalid bucket name for s3.

If the name is not set to /default,Causes the following error:
caused by: Put "http://default.127.0.0.1:9000/IMG%40%40%40%C2%A5%26_0960.JPG": dial tcp: lookup default.127.0.0.1 on 1.2.4.8:53: no such host

@minhjh
Copy link
Author

minhjh commented Sep 4, 2021

Hello, can you also paste the error response here?

0 write: Storager s3 {Name: /default, WorkDir: /}, [IMG@@@¥&_0960.JPG]: unexpected: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.status code: 403, request id: 16A1779B7B3E2DF9, host id:

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 4, 2021

If the name is not set to /default,Causes the following error:
caused by: Put "http://default.127.0.0.1:9000/IMG%40%40%40%C2%A5%26_0960.JPG": dial tcp: lookup default.127.0.0.1 on 1.2.4.8:53: no such host

This is by design, we need to use s3.WithForcePathStyle to enable path style API if the endpoint is an IP. It's a comment mistake, we will add it into s3 service's doc.

0 write: Storager s3 {Name: /default, WorkDir: /}, [IMG@@@¥&_0960.JPG]: unexpected: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.status code: 403, request id: 16A1779B7B3E2DF9, host id:

I believe it's caused by the incorrect bucket name. Let's solve it by s3.WithForcePathStyle, could you give it a try?

@minhjh
Copy link
Author

minhjh commented Sep 4, 2021

If the name is not set to /default,Causes the following error:
caused by: Put "http://default.127.0.0.1:9000/IMG%40%40%40%C2%A5%26_0960.JPG": dial tcp: lookup default.127.0.0.1 on 1.2.4.8:53: no such host

This is by design, we need to use s3.WithForcePathStyle to enable path style API if the endpoint is an IP. It's a comment mistake, we will add it into s3 service's doc.

0 write: Storager s3 {Name: /default, WorkDir: /}, [IMG@@@¥&_0960.JPG]: unexpected: SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.status code: 403, request id: 16A1779B7B3E2DF9, host id:

I believe it's caused by the incorrect bucket name. Let's solve it by s3.WithForcePathStyle, could you give it a try?

yep, s3.withForcepathstyle is required

@minhjh minhjh closed this as completed Sep 4, 2021
@minhjh minhjh reopened this Sep 4, 2021
@minhjh minhjh closed this as completed Sep 4, 2021
@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 4, 2021

@jiaming-he , Do you have time to change the description of force_path_style in the s3 documentation located at https://github.com/beyondstorage/site/blob/master/docs/go-storage/services/s3.md#servicer. Maybe we can add a simple sentence to inform users that we have to enable this if the endpoint is an IP.

GitHub
Source files of https://beyondstorage.io. Contribute to beyondstorage/site development by creating an account on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants