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/Download objects occurs SignatureDoesNotMatch when object key contains non-ascii character #436

Open
lidong-jimi opened this issue Sep 3, 2024 · 0 comments

Comments

@lidong-jimi
Copy link

lidong-jimi commented Sep 3, 2024

final s3Client = S3(
        region: region,
        credentials: AwsClientCredentials(
            accessKey: credentials.accessKeyId!,
            secretKey: credentials.secretAccessKey!,
            sessionToken: credentials.sessionToken));
    try {
      final contentType = await FileUtil.getFileContentType(filePath);
      final body = await File(filePath).readAsBytes();
      final objectResponse = await s3Client.putObject(
          bucket: "MyTestBucket",
          key: "テスト.jpeg",
          body: body,
          contentType: contentType);
      return filePath;
    } catch (e) {
      print('S3:::PutObject: $key failed, reason: $e');
      rethrow;
    }

When object key contains non-ascii character, there will be errors when uploading or downloading.
Even if encoding the object key by Uri.encodeComponent("テスト.jpeg"), the same error will still be reported.
Error message:
SignatureDoesNotMatch null: The request signature we calculated does not match the signature you provid Check your key and signing method.

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