Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
add 0.11.16
Browse files Browse the repository at this point in the history
- Add `changeMessageVisibility` in `S3Service`
- Support `original_filename` of function `createPresignedUrl` in `S3Service`
  • Loading branch information
kobi97 committed Dec 18, 2019
1 parent 4617cd6 commit b72a15d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [0.11.16] - 2019-12-18
## Added
- Add `changeMessageVisibility` in `S3Service`
## Changed
- Support `original_filename` of function `createPresignedUrl` in `S3Service`

## [0.11.15] - 2019-10-31
## Added
- Add `SignalManager` in `System` namespace
Expand Down
7 changes: 6 additions & 1 deletion lib/AWS/S3Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,12 @@ public function headObject(string $src)
* @param int|string|\DateTime $expires The time at which the URL should
* expire. This can be a Unix timestamp, a PHP DateTime object, or a
* string that can be evaluated by strtotime.
* @param string|null $original_filename
*
* @return string|null
* @throws MsgException
*/
public function createPresignedUrl(string $src, $expires): ?string
public function createPresignedUrl(string $src, $expires, string $original_filename = null): ?string
{
if (!$this->doesObjectExist($src)) {
return null;
Expand All @@ -120,6 +121,10 @@ public function createPresignedUrl(string $src, $expires): ?string
'Key' => $uri['key'],
];

if ($original_filename !== null) {
$params['ResponseContentDisposition'] = 'attachment; filename ="' . $original_filename . '"';
}

try {
$cmd = $this->client->getCommand('GetObject', $params);
$request = $this->client->createPresignedRequest($cmd, $expires);
Expand Down
20 changes: 20 additions & 0 deletions lib/AWS/SqsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,24 @@ public function deleteMessage(string $queue_url, string $receipt_handle): void
throw $e;
}
}

public function changeMessageVisibility(string $queue_url, string $receipt_handle, int $visibility_timeout): void
{
$params = [
'QueueUrl' => $queue_url,
'ReceiptHandle' => $receipt_handle,
'VisibilityTimeout' => $visibility_timeout,
];

try {
$this->client->changeMessageVisibility($params);
} catch (AwsException $e) {
SentryHelper::triggerSentryMessage(
'Fail To Change Visibility: ' . $receipt_handle . ' From :' . $queue_url . PHP_EOL
. 'Reason : ' . PHP_EOL
. $e->getMessage()
);
throw $e;
}
}
}

0 comments on commit b72a15d

Please sign in to comment.