forked from mtusi2026/mtusi2026lab5
36 lines
1003 B
C++
36 lines
1003 B
C++
// Small smoke tool for step 4: put → get → delete against MinIO.
|
|
#include "s3_client.hpp"
|
|
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
int main() {
|
|
try {
|
|
auto cfg = S3Client::from_env();
|
|
S3Client s3(cfg);
|
|
|
|
const std::string key = "smoke/step4.txt";
|
|
const std::string payload = "lab4-s3-smoke-ok";
|
|
std::istringstream in(payload);
|
|
s3.put_object(key, in, static_cast<std::int64_t>(payload.size()),
|
|
"text/plain");
|
|
|
|
std::ostringstream out;
|
|
s3.get_object(key, out);
|
|
if (out.str() != payload) {
|
|
std::cerr << "mismatch: got [" << out.str() << "]\n";
|
|
return 2;
|
|
}
|
|
|
|
s3.delete_object(key);
|
|
std::cout << "s3_smoke: OK bucket=" << cfg.bucket << " key=" << key << "\n";
|
|
return 0;
|
|
} catch (const std::exception& e) {
|
|
std::cerr << "s3_smoke: FAIL: " << e.what() << "\n";
|
|
return 1;
|
|
}
|
|
}
|