File indexing completed on 2025-01-18 10:02:33
0001 #pragma once
0002
0003 #include <iostream>
0004 #include <sys/stat.h>
0005 #include <string>
0006 #include <vector>
0007 #include <experimental/filesystem>
0008 #include <fstream>
0009 #include <unistd.h>
0010
0011 #include <nopayloadclient/exception.hpp>
0012 #include <nopayloadclient/config.hpp>
0013 #include <nopayloadclient/payload.hpp>
0014 #include <nopayloadclient/payloadiov.hpp>
0015
0016
0017 namespace nopayloadclient {
0018
0019 using nlohmann::json;
0020 using std::string;
0021
0022 class PLHandler {
0023 public:
0024 PLHandler() {};
0025 PLHandler(const json& config);
0026
0027 void prepareUploadFile(const Payload& pl);
0028 void uploadFile(const Payload& pl);
0029 string getFirstGoodUrl(const Payload& pl);
0030 string getFirstGoodUrl(const string& remote_url);
0031 void decoratePrefixes(json& payload_iovs);
0032 void checkFileExists(const string& url);
0033 private:
0034 string write_dir_;
0035 std::vector<string> read_dir_list_;
0036 bool fileExists(const string& url);
0037 void checkRemoteFile(const string& url);
0038 void checkRemoteDirExists();
0039 void createDirectory(const string& path);
0040 void copyFile(const string& local_url, const string& remote_url);
0041 };
0042
0043 }