Skip to content

Commit a908ea3

Browse files
committed
aliyunoss OssClient
1 parent 112a69d commit a908ea3

File tree

5 files changed

+42
-11
lines changed

5 files changed

+42
-11
lines changed

build/sample/cpp-sdk-sample.vcxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@
9696
<MultiProcessorCompilation>true</MultiProcessorCompilation>
9797
<Optimization>Disabled</Optimization>
9898
<PrecompiledHeader>NotUsing</PrecompiledHeader>
99-
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
99+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
100100
<RuntimeTypeInfo>true</RuntimeTypeInfo>
101101
<UseFullPaths>false</UseFullPaths>
102102
<WarningLevel>Level3</WarningLevel>
103103
<PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;PLATFORM_WINDOWS;CMAKE_INTDIR="Debug"</PreprocessorDefinitions>
104104
<ObjectFileName>$(IntDir)</ObjectFileName>
105+
<LanguageStandard>stdcpp17</LanguageStandard>
105106
</ClCompile>
106107
<ResourceCompile>
107108
<PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_DEBUG;_WINDOWS;PLATFORM_WINDOWS;CMAKE_INTDIR=\"Debug\"</PreprocessorDefinitions>
@@ -139,14 +140,15 @@
139140
<MultiProcessorCompilation>true</MultiProcessorCompilation>
140141
<Optimization>MaxSpeed</Optimization>
141142
<PrecompiledHeader>NotUsing</PrecompiledHeader>
142-
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
143+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
143144
<RuntimeTypeInfo>true</RuntimeTypeInfo>
144145
<UseFullPaths>false</UseFullPaths>
145146
<WarningLevel>Level3</WarningLevel>
146147
<PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;PLATFORM_WINDOWS;CMAKE_INTDIR="Release"</PreprocessorDefinitions>
147148
<ObjectFileName>$(IntDir)</ObjectFileName>
148149
<DebugInformationFormat>
149150
</DebugInformationFormat>
151+
<LanguageStandard>stdcpp17</LanguageStandard>
150152
</ClCompile>
151153
<ResourceCompile>
152154
<PreprocessorDefinitions>%(PreprocessorDefinitions);WIN32;_WINDOWS;NDEBUG;PLATFORM_WINDOWS;CMAKE_INTDIR=\"Release\"</PreprocessorDefinitions>

build/sample/infoss.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
#include "infoss.h"
1+
#include <alibabacloud/oss/OssClient.h>
2+
using namespace AlibabaCloud::OSS;
3+
4+
#include "..\..\..\build\infoss.h"
5+
6+
//int main(int argc, char** argv)
7+
int main(void)
8+
{
9+
// 初始化SDK
10+
InitializeSdk();
11+
12+
// 配置实例
13+
ClientConfiguration conf;
14+
conf.verifySSL = false;
15+
OssClient client(INFOSS_REGION_ID, INFOSS_ACCESS_KEY_ID, INFOSS_ACCESS_KEY_SECRET, conf);
16+
17+
// 创建API请求
18+
ListBucketsRequest request;
19+
auto outcome = client.ListBuckets(request);
20+
if (!outcome.isSuccess()) {
21+
// 异常处理
22+
std::cout << "ListBuckets fail" <<
23+
",code:" << outcome.error().Code() <<
24+
",message:" << outcome.error().Message() <<
25+
",requestId:" << outcome.error().RequestId() << std::endl;
26+
ShutdownSdk();
27+
return -1;
28+
}
29+
30+
31+
32+
// 关闭SDK
33+
ShutdownSdk();
34+
return 0;
35+
}

build/sample/infoss.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

build/sdk/cpp-sdk.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<MultiProcessorCompilation>true</MultiProcessorCompilation>
8989
<Optimization>Disabled</Optimization>
9090
<PrecompiledHeader>NotUsing</PrecompiledHeader>
91-
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
91+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
9292
<RuntimeTypeInfo>true</RuntimeTypeInfo>
9393
<UseFullPaths>false</UseFullPaths>
9494
<WarningLevel>Level3</WarningLevel>
@@ -121,7 +121,7 @@
121121
<MultiProcessorCompilation>true</MultiProcessorCompilation>
122122
<Optimization>MaxSpeed</Optimization>
123123
<PrecompiledHeader>NotUsing</PrecompiledHeader>
124-
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
124+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
125125
<RuntimeTypeInfo>true</RuntimeTypeInfo>
126126
<UseFullPaths>false</UseFullPaths>
127127
<WarningLevel>Level3</WarningLevel>

sample/src/Program.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void LogCallbackFunc(LogLevel level, const std::string &stream)
2828
std::cout << stream;
2929
}
3030

31-
int main(void)
31+
int mainz(void)
3232
{
3333
std::cout << "oss-cpp-sdk samples" << std::endl;
3434
std::string bucketName = "<YourBucketName>";

0 commit comments

Comments
 (0)