Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CF R2 Support #1206

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Source/s3stream/S3ObjectStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "StdStreamUtils.h"
#include "Log.h"

#define PREF_S3_OBJECTSTREAM_PROVIDER "s3.objectstream.provider"
#define PREF_R2_OBJECTSTREAM_ACCOUNTKEYID "r2.objectstream.accountkeyid"
#define PREF_S3_OBJECTSTREAM_ACCESSKEYID "s3.objectstream.accesskeyid"
#define PREF_S3_OBJECTSTREAM_SECRETACCESSKEY "s3.objectstream.secretaccesskey"
#define CACHE_PATH "Play Data Files/s3objectstream_cache"
Expand All @@ -21,14 +23,18 @@ CS3ObjectStream::CConfig::CConfig()
{
CAppConfig::GetInstance().RegisterPreferenceString(PREF_S3_OBJECTSTREAM_ACCESSKEYID, "");
CAppConfig::GetInstance().RegisterPreferenceString(PREF_S3_OBJECTSTREAM_SECRETACCESSKEY, "");
CAppConfig::GetInstance().RegisterPreferenceString(PREF_R2_OBJECTSTREAM_ACCOUNTKEYID, "");
CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_S3_OBJECTSTREAM_PROVIDER, CAmazonConfigs::AWS_S3);
}

CAmazonCredentials CS3ObjectStream::CConfig::GetCredentials()
CAmazonConfigs CS3ObjectStream::CConfig::GetConfigs()
{
CAmazonCredentials credentials;
credentials.accessKeyId = CAppConfig::GetInstance().GetPreferenceString(PREF_S3_OBJECTSTREAM_ACCESSKEYID);
credentials.secretAccessKey = CAppConfig::GetInstance().GetPreferenceString(PREF_S3_OBJECTSTREAM_SECRETACCESSKEY);
return credentials;
CAmazonConfigs configs;
configs.accessKeyId = CAppConfig::GetInstance().GetPreferenceString(PREF_S3_OBJECTSTREAM_ACCESSKEYID);
configs.secretAccessKey = CAppConfig::GetInstance().GetPreferenceString(PREF_S3_OBJECTSTREAM_SECRETACCESSKEY);
configs.accountKeyId = CAppConfig::GetInstance().GetPreferenceString(PREF_R2_OBJECTSTREAM_ACCOUNTKEYID);
configs.m_provider = static_cast<CAmazonConfigs::S3PROVIDER>(CAppConfig::GetInstance().GetPreferenceInteger(PREF_S3_OBJECTSTREAM_PROVIDER));
return configs;
}

CS3ObjectStream::CS3ObjectStream(const char* bucketName, const char* objectKey)
Expand Down Expand Up @@ -133,7 +139,7 @@ void CS3ObjectStream::GetObjectInfo()
{
//Obtain bucket region
{
CAmazonS3Client client(CConfig::GetInstance().GetCredentials());
CAmazonS3Client client(CConfig::GetInstance().GetConfigs());

GetBucketLocationRequest request;
request.bucket = m_bucketName;
Expand All @@ -144,7 +150,7 @@ void CS3ObjectStream::GetObjectInfo()

//Obtain object info
{
CAmazonS3Client client(CConfig::GetInstance().GetCredentials(), m_bucketRegion);
CAmazonS3Client client(CConfig::GetInstance().GetConfigs(), m_bucketRegion);

HeadObjectRequest request;
request.bucket = m_bucketName;
Expand Down Expand Up @@ -193,7 +199,7 @@ void CS3ObjectStream::SyncBuffer()
if(!cachedReadSucceeded)
{
assert(size > 0);
CAmazonS3Client client(CConfig::GetInstance().GetCredentials(), m_bucketRegion);
CAmazonS3Client client(CConfig::GetInstance().GetConfigs(), m_bucketRegion);
GetObjectRequest request;
request.key = m_objectKey;
request.bucket = m_bucketName;
Expand Down
2 changes: 1 addition & 1 deletion Source/s3stream/S3ObjectStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CS3ObjectStream : public Framework::CStream
{
public:
CConfig();
CAmazonCredentials GetCredentials();
CAmazonConfigs GetConfigs();
};

CS3ObjectStream(const char*, const char*);
Expand Down
2 changes: 1 addition & 1 deletion Source/ui_qt/QBootablesView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void QBootablesView::on_awsS3Button_clicked()

ToggleInterface(false);
auto getListFuture = std::async(std::launch::async, [this, bucketName]() {
auto credentials = CS3ObjectStream::CConfig::GetInstance().GetCredentials();
auto credentials = CS3ObjectStream::CConfig::GetInstance().GetConfigs();
AsyncUpdateStatus("Requesting S3 Bucket Content.");
auto result = AmazonS3Utils::GetListObjects(credentials, bucketName);
auto size = result.objects.size();
Expand Down
4 changes: 2 additions & 2 deletions Source/ui_qt/S3FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ S3FileBrowser::~S3FileBrowser()

bool S3FileBrowser::IsAvailable()
{
return CS3ObjectStream::CConfig::GetInstance().GetCredentials().IsValid();
return CS3ObjectStream::CConfig::GetInstance().GetConfigs().IsValid();
}

fs::path S3FileBrowser::GetSelectedPath() const
Expand Down Expand Up @@ -96,7 +96,7 @@ void S3FileBrowser::launchUpdate()
updateOkButtonState();

auto getListFuture = std::async([bucketName = m_lastUpdateBucketName.toStdString()]() {
auto credentials = CS3ObjectStream::CConfig::GetInstance().GetCredentials();
auto credentials = CS3ObjectStream::CConfig::GetInstance().GetConfigs();
return AmazonS3Utils::GetListObjects(credentials, bucketName);
});
m_continuationChecker->GetContinuationManager().Register(std::move(getListFuture),
Expand Down
2 changes: 1 addition & 1 deletion Source/ui_shared/AmazonS3Utils.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "AmazonS3Utils.h"

ListObjectsResult AmazonS3Utils::GetListObjects(const CAmazonCredentials& credentials, std::string bucketName)
ListObjectsResult AmazonS3Utils::GetListObjects(const CAmazonConfigs& credentials, std::string bucketName)
{
std::string bucketRegion;

Expand Down
2 changes: 1 addition & 1 deletion Source/ui_shared/AmazonS3Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

namespace AmazonS3Utils
{
ListObjectsResult GetListObjects(const CAmazonCredentials&, std::string);
ListObjectsResult GetListObjects(const CAmazonConfigs&, std::string);
};