Hi,
i’ve a question regarding the AWS S3 storage option for the file storage of CUBA. I used the instructions from here. In local mode (running via studio) everything worked fine.
On a deployment scenario with two different tomcats and app-core.war and app.war separated, an error occurs while uploading the file to S3 (see below):
17:10:37.047 ERROR c.h.c.c.c.FileUploadController - Unable to upload file
com.haulmont.cuba.core.global.FileStorageException: I/O error: Could not save file 0ea0d0ea-8616-5097-f609-6feb822866e4.png. <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId>********</AWSAccessKeyId><StringToSign>********</CanonicalRequest><CanonicalRequestBytes>********</CanonicalRequestBytes><RequestId>FD5A06F41AAB8B17</RequestId><HostId>********</HostId></Error>
at com.haulmont.cuba.core.app.filestorage.amazon.AmazonS3FileStorage.saveStream(AmazonS3FileStorage.java:126) ~[cuba-core-6.2.3.jar:6.2.3]
The configuration did not change with the two options so i would guess that this is not the problem. The desired region is “eu-west-1”. Since i’ve no glue why this is not working in an environment with two wars in two tomcats within two docker containers but in the studio environment i just searched through the code.
I came across one thing that i don’t have any idea if it helps but perhaps you can give me an answer to this:
In the method “getAmazonUrl” of the Class AmazonS3FileStorage it says that it uses S3 - path style for the URL: “the region-specific endpoint to the target object expressed in path style”. But in the docs of AWS it says that if using path style a region specific URL has to be set (like s3-eu-west-1.amazonaws.com/… ) as described here:
<b>Important</b>
Amazon S3 supports virtual hosted-style and path-style access in all regions. The path-style syntax, however, requires that you use the region-specific endpoint when attempting to access a bucket. For example, if you have a bucket called mybucket that resides in the EU (Ireland) region, you want to use path-style syntax, and the object is named puppy.jpg, the correct URI is http://s3-eu-west-1.amazonaws.com/mybucket/puppy.jpg.
Unlike the comment says, the URL creation looks a little bit more like virtual host style if i understand the implementation correctly:
return new URL(String.format("https://%s.s3.amazonaws.com/%s", amazonS3Config.getBucket(), resolveFileName(fileDescr)));
As i said i’m not even sure if this thing has anything to do with the actual error, but it just was the first obvious straw to clutch at ![]()
Perhaps you can give me a little hint about the implementation or even about the error that occurs only in “production” mode but not in studio mode.
Bye,
Mario