Reading Shape files from AWS S3 via pre signed URL

Description

I was trying to read shape files from aws s3 bucket and was able to read if bucket is made public. But if bucket is private and I am using pre-signed urls, ShapefileDataStoreFactory.canProcess(URL f) behavior is unexpected for shape file urls having extra information as query parameter in URL.

Below url pasting in browser results downloading of the file, Also making file public and using "https://s3.us-east-2.amazonaws.com/s3-dummy-example/hello/test.shp" works as expected.

Pre Signed URL - https://s3.us-east-2.amazonaws.com/s3-dummy-example/hello/test.shp?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20181015T210314Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3599&X-Amz-Credential=*********************************************&X-Amz-Signature=*****************************************

Suggested Fix - Adding an OR condition with checking the path as well, will resolve this and won't break anything existing.

ShapefileDataStoreFactory.java

public boolean canProcess(URL f) {
return f != null && (f.getFile().toUpperCase().endsWith("SHP") || f.getPath().toUpperCase().endsWith("SHP"));
}

Environment

None

Status

Assignee

Unassigned

Reporter

Manjeet Rulhania

Triage

None

Affects versions

20.0

Priority

High
Configure