Your opinion will help to improve our service
Leave a feedback >Take a look at official S3 documentation. Have your access key and secret key ready.
In this example, we will create a client and make a request to S3 endpoint.
Find and link to userver module:
find_package(userver COMPONENTS core s3api REQUIRED)
add_library(${PROJECT_NAME}_objs OBJECT
src/s3api_client.cpp
)
target_link_libraries(${PROJECT_NAME}_objs PUBLIC userver::s3api)
target_include_directories(${PROJECT_NAME}_objs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
We recommend wrapping your clients into some component. This way you can make sure that reference to http_client outlives S3 client. It can look, for example, like this:
To create client itself, you do only few simple steps:
Here is usage example
We provide google mock for client, that you can access by including header
With this mock, you have full power of Google Mock at your fingertips:
To add tests to your project, add appropriate lines to CMakeLists.txt, like this:
add_executable(${PROJECT_NAME}-unittest unittests/client_test.cpp)
target_link_libraries(${PROJECT_NAME}-unittest
${PROJECT_NAME}_objs
userver::utest
userver::s3api-utest
)
add_google_tests(${PROJECT_NAME}-unittest)
Testsuite module is provided as part of testsuite plugins and can be found at:
testsuite/pytest_plugins/pytest_userver/plugins/s3api.py
See the full example at: