Ai
1 Star 0 Fork 0

*&c++/webdisk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
oss.cc 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
geoff 提交于 2023-08-09 23:32 +08:00 . initialize webdisk project
#include "oss.h"
#include <iostream>
#include <alibabacloud/oss/OssClient.h>
using std::cout;
using std::endl;
using namespace AlibabaCloud::OSS;
OssUploader::OssUploader(const OssInfo & info)
: _ossinfo(info)
, _conf()
, _ossclient(_ossinfo.endpoint, _ossinfo.accessKeyId, _ossinfo.accessKeySecret, _conf)
{
InitializeSdk();
}
void OssUploader::doUpload(const string & key, const string & filename)
{
/* ClientConfiguration conf; */
/* OssClient client(_ossinfo.endpoint, _ossinfo.accessKeyId, _ossinfo.accessKeySecret, conf); */
auto outcome = _ossclient.PutObject(_ossinfo.bucketname, key, filename);
if(!outcome.isSuccess()) {
cout << outcome.error().Code()
<< ", " << outcome.error().Message()
<< ", " << outcome.error().RequestId() << endl;
} else {
cout << "upload file " << filename << " sucess!" << endl;
}
}
OssUploader::~OssUploader()
{
ShutdownSdk();
}
string OssUploader::genreateDownloadUrl(const string & key)
{
/* ClientConfiguration conf; */
/* OssClient client(_ossinfo.endpoint, _ossinfo.accessKeyId, _ossinfo.accessKeySecret, conf); */
time_t t = time(nullptr) + 1200;
auto outcome = _ossclient.GeneratePresignedUrl(_ossinfo.bucketname, key, t, Http::Get);
if(!outcome.isSuccess()) {
cout << outcome.error().Code()
<< ", " << outcome.error().Message()
<< ", " << outcome.error().RequestId() << endl;
return string();
}
return outcome.result();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/learntocodewithc/webdisk.git
git@gitee.com:learntocodewithc/webdisk.git
learntocodewithc
webdisk
webdisk
master

搜索帮助