2018-02-16 17:25:45 -05:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-17 18:15:16 -04:00
|
|
|
#include <vector>
|
2018-10-09 13:06:08 -04:00
|
|
|
#include "Singleton.h"
|
2018-02-16 17:25:45 -05:00
|
|
|
#include "Stream.h"
|
2019-10-16 20:51:11 -04:00
|
|
|
#include "filesystem_def.h"
|
2021-04-22 19:06:45 -04:00
|
|
|
#include "amazon/AmazonS3Client.h"
|
2018-02-16 17:25:45 -05:00
|
|
|
|
|
|
|
class CS3ObjectStream : public Framework::CStream
|
|
|
|
{
|
|
|
|
public:
|
2018-10-09 13:06:08 -04:00
|
|
|
class CConfig : public CSingleton<CConfig>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CConfig();
|
2021-04-22 19:06:45 -04:00
|
|
|
CAmazonCredentials GetCredentials();
|
2018-10-09 13:06:08 -04:00
|
|
|
};
|
|
|
|
|
2018-02-16 17:25:45 -05:00
|
|
|
CS3ObjectStream(const char*, const char*);
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint64 Read(void*, uint64) override;
|
|
|
|
uint64 Write(const void*, uint64) override;
|
|
|
|
void Seek(int64, Framework::STREAM_SEEK_DIRECTION) override;
|
|
|
|
uint64 Tell() override;
|
|
|
|
bool IsEOF() override;
|
2018-02-16 17:25:45 -05:00
|
|
|
|
|
|
|
private:
|
2019-10-16 20:51:11 -04:00
|
|
|
static fs::path GetCachePath();
|
2018-02-19 16:46:16 -05:00
|
|
|
std::string GenerateReadCacheKey(const std::pair<uint64, uint64>&) const;
|
2018-02-16 17:25:45 -05:00
|
|
|
void GetObjectInfo();
|
2019-05-13 12:36:36 -04:00
|
|
|
void SyncBuffer();
|
2018-02-16 17:25:45 -05:00
|
|
|
|
|
|
|
std::string m_bucketName;
|
|
|
|
std::string m_bucketRegion;
|
2021-04-22 19:06:45 -04:00
|
|
|
std::string m_objectKey;
|
2018-02-19 16:46:16 -05:00
|
|
|
|
|
|
|
//Object Metadata
|
2018-02-16 17:25:45 -05:00
|
|
|
uint64 m_objectSize = 0;
|
2018-02-19 16:46:16 -05:00
|
|
|
std::string m_objectEtag;
|
|
|
|
|
2018-02-16 17:25:45 -05:00
|
|
|
uint64 m_objectPosition = 0;
|
2019-05-13 12:36:36 -04:00
|
|
|
|
|
|
|
std::vector<uint8> m_buffer;
|
|
|
|
uint64 m_bufferPosition = ~0ULL;
|
2018-02-16 17:25:45 -05:00
|
|
|
};
|