Skip to content

Commit 700f2ba

Browse files
author
Phil Varner
authored
Merge pull request #428 from stac-utils/pv/use-storage-extension-for-thumbnails
use storage:region for thumbnail generation
2 parents a6ca7a0 + a17de7a commit 700f2ba

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased] - TBD
8+
## [0.8.1] - 2023-03-29
9+
10+
### Added
11+
12+
- Thumbnail support will now look at Asset or Item level `storage:region` field
13+
to determine the region for generating the pre-signed URL for the thumbnail.
14+
Previously used the default behavior of AWS SDK.
15+
16+
## [0.8.0] - 2023-03-06
917

1018
### Added
1119

@@ -241,6 +249,8 @@ Initial release, forked from [sat-api](https://github.com/sat-utils/sat-api/tree
241249

242250
Compliant with STAC 0.9.0
243251

252+
[0.8.1]: https://github.com/stac-utils/stac-api/compare/v0.8.0...v0.8.1
253+
[0.8.0]: https://github.com/stac-utils/stac-api/compare/v0.7.0...v0.8.0
244254
[0.7.0]: https://github.com/stac-utils/stac-api/compare/v0.6.0...v0.7.0
245255
[0.6.0]: https://github.com/stac-utils/stac-api/compare/v0.5.2...v0.6.0
246256
[0.5.2]: https://github.com/stac-utils/stac-api/compare/v0.4.1...v0.5.2

src/lib/api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,14 @@ const getItemThumbnail = async function (collectionId, itemId, backend) {
920920
if (thumbnailAsset.href && thumbnailAsset.href.startsWith('http')) {
921921
location = thumbnailAsset.href
922922
} else if (thumbnailAsset.href && thumbnailAsset.href.startsWith('s3')) {
923+
const region = thumbnailAsset['storage:region']
924+
|| item.properties['storage:region']
925+
|| process.env['AWS_REGION']
926+
|| 'us-west-2'
923927
const withoutProtocol = thumbnailAsset.href.substring(5) // chop off s3://
924928
const [bucket, ...keyArray] = withoutProtocol.split('/')
925929
const key = keyArray.join('/')
926-
location = new AWS.S3().getSignedUrl('getObject', {
930+
location = new AWS.S3({ region }).getSignedUrl('getObject', {
927931
Bucket: bucket,
928932
Key: key,
929933
Expires: 60 * 5, // expiry in seconds

0 commit comments

Comments
 (0)