minio / minio-cpp

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

Suggestion: Use std::ios::binary flag when opening files for upload #174

Closed HMS-Yukikaze closed 1 month ago

HMS-Yukikaze commented 1 month ago

https://github.com/mrjimenez/pupnp-backup/blob/c61460be44645f5c9040c1cf4cf7ac5efbe6b01d/cmake/CmDaB.cmake#L43 I encountered an issue when using the library for file uploads.

Description

The file is currently opened using file.open(args.filename);, which does not include the std::ios::binary flag. This causes problems when uploading non-text files (e.g., binary files like images or executables). To properly handle these types of files, it is recommended to open the file using file.open(args.filename, std::ios::binary);

Steps to Reproduce:

  1. up an *.psd file to the oss sever
  2. error in line:https://github.com/minio/minio-cpp/blob/40824d0872861b06965a032a714a8f4f9097fb32/src/utils.cc#L601 OS: Windows 11 22631.4037 Compiler:MSVC 2019 X64
balamurugana commented 1 month ago

Duplicate https://github.com/minio/minio-cpp/issues/145