spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

Exclude Slash from Encode, when calling getURL()

Open songintae opened this issue 3 years ago • 4 comments

:loudspeaker: Type of change

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

:scroll: Description

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

:bulb: 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.

  1. AmazonS3
  2. SimpleStorageProtocolResolver
  3. 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.

:green_heart: How did you test it?

Modified the existing test code.

:pencil: 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

:crystal_ball: Next steps

songintae avatar Jan 16 '22 08:01 songintae

@songintae Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

pivotal-cla avatar Jan 16 '22 08:01 pivotal-cla

@songintae Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

pivotal-cla avatar Jan 16 '22 08:01 pivotal-cla

@songintae Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

pivotal-cla avatar Jan 16 '22 08:01 pivotal-cla

@songintae Thank you for signing the Contributor License Agreement!

pivotal-cla avatar Jan 16 '22 08:01 pivotal-cla