Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-01 22:41:11

0001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
0002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
0003 #include "Utilities/StorageFactory/interface/StorageFactory.h"
0004 #include "Utilities/StorageFactory/interface/RemoteFile.h"
0005 
0006 namespace edm::storage {
0007   class HttpStorageMaker : public StorageMaker {
0008   public:
0009     std::unique_ptr<Storage> open(const std::string &proto,
0010                                   const std::string &path,
0011                                   int mode,
0012                                   const AuxSettings &) const override {
0013       std::string temp;
0014       const StorageFactory *f = StorageFactory::get();
0015       int localfd = RemoteFile::local(f->tempDir(), temp);
0016       std::string newurl((proto == "web" ? "http" : proto) + ":" + path);
0017       const char *curlopts[] = {"curl", "-L", "-f", "-o", temp.c_str(), "-q", "-s", "--url", newurl.c_str(), nullptr};
0018 
0019       return RemoteFile::get(localfd, temp, (char **)curlopts, mode);
0020     }
0021   };
0022 }  // namespace edm::storage
0023 
0024 using namespace edm::storage;
0025 DEFINE_EDM_PLUGIN(StorageMakerFactory, HttpStorageMaker, "ftp");