Skip to content

Conversation

willome
Copy link
Contributor

@willome willome commented Apr 29, 2022

📢 Type of change

  • [ x ] Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

This is a new PR replacing the old one on the legacy repository : spring-attic/spring-cloud-aws#805 made by @songintae

In the PathResourceResolver.isResourceUnderLocation method, a slash is placed in the locationPath to verify the resource. Therefore, the slash should be excluded when encoding the object name.

PathResourceResolver class : org.springframework.web.servlet.resource.PathResourceResolver

💡 Motivation and Context

I am using S3 to manage static resources.
Using the spring, I wrote the setting code as follows.

-- application.yml
spring.resources.staticLocations:

  • 's3://bucketName/admin/beta/'

And I registered the following Beans.

AmazonS3
SimpleStorageProtocolResolver
SimpleStorageProtocolResolverConfigurer
In this environment, when I make a request such as "https://domain.com/index.html", the PathResourceResolver.isResourceUnderLocation method does not find the file correctly due to URL encoding problems.

💚 How did you test it?

Modified the existing test code.

📝 Checklist

  • I reviewed submitted code
  • [ x ] I added tests to verify changes
  • I updated reference documentation to reflect the change
  • [ x ] All tests passing
  • [ x ] No breaking changes

🔮 Next steps

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@maciejwalkowiak maciejwalkowiak added type: bug Something isn't working component: s3 S3 integration related issue labels Apr 29, 2022
@maciejwalkowiak maciejwalkowiak added this to the 3.0.0 M1 milestone Apr 29, 2022
@maciejwalkowiak maciejwalkowiak merged commit 22c961d into awspring:main Apr 29, 2022
@maciejwalkowiak
Copy link
Contributor

Thanks @willome!

@willome willome deleted the bugfix-simple-storage-resource branch May 30, 2022 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: s3 S3 integration related issue type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants