@@ -226,7 +226,8 @@ struct NetworkContext
226226 */
227227static bool printS3ObjectFilePresignedURL ( const char * pHost ,
228228 size_t hostLen ,
229- const char * pPath );
229+ const char * pPath ,
230+ const bool is_get );
230231
231232/**
232233 * @brief CryptoInterface provided to SigV4 library for generating the hash digest.
@@ -261,7 +262,8 @@ static SigV4Parameters_t sigv4Params =
261262
262263static bool printS3ObjectFilePresignedURL ( const char * pHost ,
263264 size_t hostLen ,
264- const char * pPath )
265+ const char * pPath ,
266+ const bool is_get )
265267{
266268 bool returnStatus = true;
267269 HTTPStatus_t httpStatus = HTTPSuccess ;
@@ -291,8 +293,16 @@ static bool printS3ObjectFilePresignedURL( const char * pHost,
291293 /* Initialize the request object. */
292294 requestInfo .pHost = pHost ;
293295 requestInfo .hostLen = hostLen ;
294- requestInfo .pMethod = HTTP_METHOD_GET ;
295- requestInfo .methodLen = sizeof ( HTTP_METHOD_GET ) - 1 ;
296+ if ( is_get )
297+ {
298+ requestInfo .pMethod = HTTP_METHOD_GET ;
299+ requestInfo .methodLen = sizeof ( HTTP_METHOD_GET ) - 1 ;
300+ }
301+ else
302+ {
303+ requestInfo .pMethod = HTTP_METHOD_PUT ;
304+ requestInfo .methodLen = sizeof ( HTTP_METHOD_PUT ) - 1 ;
305+ }
296306 requestInfo .pPath = pPath ;
297307 requestInfo .pathLen = strlen ( pPath );
298308
@@ -523,9 +533,20 @@ int main( int argc,
523533
524534 if ( returnStatus == EXIT_SUCCESS )
525535 {
536+ LogInfo ( ( "HTTP_METHOD_GET:" ) );
526537 ret = printS3ObjectFilePresignedURL ( serverHost ,
527538 serverHostLength ,
528- pPath );
539+ pPath ,
540+ true/*is_get*/ );
541+
542+ if ( ret )
543+ {
544+ LogInfo ( ( "HTTP_METHOD_PUT:" ) );
545+ ret = printS3ObjectFilePresignedURL ( serverHost ,
546+ serverHostLength ,
547+ pPath ,
548+ false/*is_get*/ );
549+ }
529550
530551 returnStatus = ( ret == true ) ? EXIT_SUCCESS : EXIT_FAILURE ;
531552 }
0 commit comments