| 1375 | |
| 1376 | template <typename ObjectRequest> |
| 1377 | Status SetObjectMetadata(const std::shared_ptr<const KeyValueMetadata>& metadata, |
| 1378 | ObjectRequest* req) { |
| 1379 | static auto setters = ObjectMetadataSetter<ObjectRequest>::GetSetters(); |
| 1380 | |
| 1381 | DCHECK_NE(metadata, nullptr); |
| 1382 | const auto& keys = metadata->keys(); |
| 1383 | const auto& values = metadata->values(); |
| 1384 | |
| 1385 | for (size_t i = 0; i < keys.size(); ++i) { |
| 1386 | auto it = setters.find(keys[i]); |
| 1387 | if (it != setters.end()) { |
| 1388 | RETURN_NOT_OK(it->second(values[i], req)); |
| 1389 | } |
| 1390 | } |
| 1391 | return Status::OK(); |
| 1392 | } |
| 1393 | |
| 1394 | bool IsDirectory(std::string_view key, const S3Model::HeadObjectResult& result) { |
| 1395 | // If it has a non-zero length, it's a regular file. We do this even if |