Skip to content

S3 Upload/Download objects occurs SignatureDoesNotMatch when object key contains non-ascii character #436

@lidong-jimi

Description

@lidong-jimi
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions