minio-dart icon indicating copy to clipboard operation
minio-dart copied to clipboard

Info: MinioS3Error MinioError: The security token included in the request is invalid

Open doralines opened this issue 1 year ago • 3 comments

I think my sessionToken is free of exceptions, and I have verified it in the sdk of the other end

doralines avatar Jan 29 '24 06:01 doralines

What I use is fputObject() image

doralines avatar Jan 29 '24 06:01 doralines

Add a line to minio_uploader.dart add_stream function:

if (!client.enableSHA256) {
  md5digest = md5.convert(chunk).bytes;
  headers['Content-MD5'] = base64.encode(md5digest);
}
headers['x-amz-security-token'] = minio.sessionToken ?? '';     // add this line

Don't know why the author didn't add x-amz-security-tokey to the headers. @doralines

serious198706 avatar Feb 23 '24 14:02 serious198706

I've added @serious198706 answer to my fork (conditionally) if anyone needs it...

Future addStream(Stream<Uint8List> stream) async {
  await for (var chunk in stream) {
    List<int>? md5digest;
    final headers = <String, String>{};
    headers.addAll(metadata);
    headers['Content-Length'] = chunk.length.toString();
    if (!client.enableSHA256) {
      md5digest = md5.convert(chunk).bytes;
      headers['Content-MD5'] = base64.encode(md5digest);
    }
    if (minio.sessionToken != null) {
      headers['x-amz-security-token'] = minio.sessionToken;  // add this line
    }

minio: git: url: https://github.com/jpetro416/minio-dart

jpetro416 avatar May 27 '24 18:05 jpetro416

Resolved, please update to v3.5.1

lijy91 avatar Sep 13 '24 13:09 lijy91