Forum

Thread tagged as: Configuration, Gallery, Members

Create Gallery Album in a secure bucket

I am looking to create albums in a secure bucket so that I can display client photos to them without the images being publicly available (I believe I can do this using the secure downloads options and utilising the flag to render a link).

However, how do I go about setting where the Gallery app will save images? I changed my perch settings so that the default bucket is "secure" and I have set up the buckets.php file to use that as the default resource bucket too.But if I create a gallery album it is still in the wrong place

Stefan Wright

Stefan Wright 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

if I create a gallery album it is still in the wrong place

Could you detail your steps?

Drew McLellan said:

if I create a gallery album it is still in the wrong place

Could you detail your steps?

Sure, I login to the admin area, I go into Gallery, I then click the button to "+ Add album", I then create an ablum called "test to go in secure". Then if I look via SFTP the folder is created in my httpd.www>perch>resources folder. I would be expecting it to be in httpd.private>'album name'

I am using one.com for my hosting and their documentation implies you can use the httpd.private as a private document area which is outside of the www root

my buckets.config is:

<?php return array( 'secure' => array( 'web_path' => '/members/download.php?file=', 'file_path' => $_SERVER['ONECOM_DOMAIN_ROOT'] . 'httpd.private', ) ); ?>

It would seem that is being ignored though.

In my settings screen under gallery it is set to "Store images in one bucket per album" and the "default resource" bucket is set to "secure"

Is this enough to go on?

Is the issue because the PERCH_RESFILEPATH is /customers/4/f/9/stefan-wright.com/httpd.www/perch/resources so I have to change that? I didnt think I needed to as is not mentioned in the help article for secure member downloads

Drew McLellan

Drew McLellan 2638 points
Perch Support

The bucket's own file path overwrites that path, which is essentially just for the default bucket.

What value have you set in Settings for the Gallery bucket?

Hi Drew,

I did mention the before. In my settings screen under gallery it is set to "Store images in one bucket per album" and the "default resource" bucket is set to "secure"

Drew McLellan

Drew McLellan 2638 points
Perch Support

You don't want to use "Store images in one bucket per album" if you're storing in a specified bucket. Those options logically conflict.

Drew McLellan said:

You don't want to use "Store images in one bucket per album" if you're storing in a specified bucket. Those options logically conflict.

Right ok :S I presumed that it would work similarly to posting the images to the resources folder so that I would have secure/00001, secure/00002 (the numbers being a client number for example). Is there any way in which I can have the buckets created via the gallery, but into a secure folder?

Hey, I have sorted a solution now to fit in to my workflow.

For anyone interested:

I have created a Database Table called bucketConfig. In that table I am simply storing the customer reference number. I then edited the bucket.config file so that it runs a DB query to fetch those references. This DB query rebuilds the array for the config file. This new array is what is then returned.

Code below: $sql = "SELECT clientRef FROM bucketsPHP"; $results = mysqli_query($conn, $sql);

$bucketArray = array(); while ($row = mysqli_fetch_assoc($results)) { $clientRef = str_pad($row['clientRef'], 5, '0', STR_PAD_LEFT); $bucketArray[$clientRef] = array('web_path' => '/weddings/clients/download.php?clientId='. $clientRef.'&file=', 'file_path' => $_SERVER['ONECOM_DOMAIN_ROOT'] . 'httpd.private/'.$clientRef.'',); } return $bucketArray;