minio / minio-cpp

MinIO C++ Client SDK for Amazon S3 Compatible Cloud Storage
https://minio-cpp.min.io/
Apache License 2.0
127 stars 53 forks source link

PutObject file size issue #152

Closed skydream-xu closed 2 months ago

skydream-xu commented 2 months ago

`` minio::s3::BaseUrl base_url("xxxxxx:9000", false);

// Create credential provider.
minio::creds::StaticProvider provider(
    "xxxx", "xxxxx");

// Create S3 client.
minio::s3::Client client(base_url, &provider);

// Create put object arguments.
std::ifstream file("d:/test.step",std::ios::in);
file.seekg(0, std::ios::end);

std::streamsize size = file.tellg();
file.seekg(0, std::ios::beg);
minio::s3::PutObjectArgs args(file, size, 0);
args.bucket = "xhb";
args.object = "test.step";

// Call put object.
minio::s3::PutObjectResponse resp = client.PutObject(args);

run env: windows

Error info : not enough data in the stream; expected: 146060, got: 142859 bytes

balamurugana commented 2 months ago
  1. Check your file size in the OS
  2. Use proper open flags