Skip to content

Commit

Permalink
Adding an optional timeout to the s3 putObject function (#73)
Browse files Browse the repository at this point in the history
* Update api.cfc

* Adding timeout option to s3.cfc
  • Loading branch information
garciadev authored Mar 29, 2023
1 parent f15932c commit 187b85f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion com/api.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ component accessors="true" {
any body = '',
struct awsCredentials = { },
boolean encodeurl = true,
boolean useSSL = true
boolean useSSL = true,
numeric timeout = 0
) {
if ( awsCredentials.isEmpty() ) {
awsCredentials = credentials.getCredentials();
Expand Down Expand Up @@ -86,6 +87,7 @@ component accessors="true" {
httpArgs[ 'queryParams' ] = queryParams;
httpArgs[ 'useSSL' ] = useSSL;
if ( !isNull( arguments.body ) ) httpArgs[ 'body' ] = body;
if ( timeout ) httpArgs[ 'timeout' ] = timeout;
// writeDump( httpArgs );

var requestStart = getTickCount();
Expand Down
12 changes: 8 additions & 4 deletions services/s3.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ component {
string Expires = '',
struct Metadata = { },
string StorageClass = '',
string WebsiteRedirectLocation = ''
string WebsiteRedirectLocation = '',
numeric timeout = 0
) {
var requestSettings = api.resolveRequestSettings( argumentCollection = arguments );
var headers = { };
Expand Down Expand Up @@ -648,7 +649,8 @@ component {
'/' & ObjectKey,
{ },
headers,
FileContent
FileContent,
timeout
);
return apiResponse;
}
Expand Down Expand Up @@ -903,7 +905,8 @@ component {
string path = '/',
struct queryParams = { },
struct headers = { },
any payload = ''
any payload = '',
numeric timeout = 0
) {
var host = getHost( requestSettings );

Expand Down Expand Up @@ -935,7 +938,8 @@ component {
payload,
requestSettings.awsCredentials,
false,
useSSL
useSSL,
timeout
);
}

Expand Down

0 comments on commit 187b85f

Please sign in to comment.