cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Custom folder for S3 storage

Former Member
0 Likes
543

When using the s3MediaStorageStrategy, is there a way I can specify a root folder to use within the S3 bucket?

I have tried these:

 media.globalSettings.s3MediaStorageStrategy.bucketId=my_bucket_id/my_folder
 media.globalSettings.s3MediaStorageStrategy.bucketId=my_bucket_id:/my_folder

Thanks!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Likes

Hi Patrick,

Thanks for your very detailed answer.

As you pointed out, Hybris will use (and generate by default) a folder named sys-master.

In our S3 bucket we have a few additional folders that are not managed by Hybris, so I was hoping to be able to specify a name for the Hybris media folder. The structure would be something like

 bucket
 -- external_media
 -- hybris_media
 ---- sys-master
 ------ s3medias

There's no technical reason or requirement for this. I will just use the sys-master folder on the root level, or might use a different bucket.

Thanks!

Former Member
0 Likes

Whats your use case? I think it would be better to create multiple buckets or multiple mediafolders in the same bucket.

Our bucket folder hierarchy looks like this

 bucket
 --sys-master
 ----s3medias

Our configuration for one media folder.

We're using an mixed solution (s3 bucket + local media folder).

First create an media folder via impex then create an s3 bucket + accessKey with full permission to s3 bucket and add the configuration for the media folder to your local.properties file.

Impex

Impex for creating media folder:

 INSERT_UPDATE MediaFolder;qualifier[unique=true];path[unique=true]
 ;s3medias;s3medias

AWS

Create an bucket which supports v2 authentication. Newer buckets with v4 authentication will not work and you will receive bad requests. For example Germany/Frankfurt wasn't working for me.

Create Access key + secret with s3-full group

Add this to your bucket permission for public read access: (change bucketname)

 {
     "Version": "2008-10-17",
     "Statement": [
         {
             "Sid": "AllowPublicRead",
             "Effect": "Allow",
             "Principal": {
                 "AWS": "*"
             },
             "Action": "s3:GetObject",
             "Resource": "arn:aws:s3:::<BUCKETNAME>/*"
         }
     ]
 }

local.properties

S3 bucket configuration we're using: (change key, secret and bucketname)

 # Amazon S3 Bucket
 media.globalSettings.s3MediaStorageStrategy.accessKeyId=<KEY>
 media.globalSettings.s3MediaStorageStrategy.secretAccessKey=<SECRET>
 media.globalSettings.s3MediaStorageStrategy.url.signed=false
 media.globalSettings.s3MediaStorageStrategy.cleanOnInit=true
  
 # Put Spring bean id of the S3 strategy that keeps the logic responsible for communication between hybris and Amazon S3
 media.folder.s3medias.bucketId=<BUCKETNAME>
 media.folder.s3medias.storage.strategy=s3MediaStorageStrategy
 media.folder.s3medias.url.strategy=s3MediaURLStrategy

Hybris documentation: https://wiki.hybris.com/display/release5/Using+Amazon+S3+Media+Storage+Strategy