Announcement

#1 2016-12-30 04:58:27

djnoah
Member
2016-12-30
15

Add pictures from locally mounted drive

Hi,

I have a mount external drive connected to the ubuntu machine that serves piwigo.  Is there anyway to add those pictures from the drive to multiple albums? 

Piwigo version:  2.8.3
PHP version: 5.5.9-1ubuntu4.20
MySQL version: Ver 14.14 Distrib 5.5.53
Piwigo URL:

Cheers

Offline

 

#2 2016-12-30 14:31:58

flop25
Piwigo Team
2006-07-06
7031

Re: Add pictures from locally mounted drive

Hello
use symlink


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2016-12-30 19:17:30

djnoah
Member
2016-12-30
15

Re: Add pictures from locally mounted drive

Okay, sounds easy enough.   where do I put the symlink?

Offline

 

#4 2016-12-30 19:36:59

flop25
Piwigo Team
2006-07-06
7031

Re: Add pictures from locally mounted drive

See the FTP+Synchronization method for adding picture


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#5 2016-12-31 02:01:20

djnoah
Member
2016-12-30
15

Re: Add pictures from locally mounted drive

Okay I am able to synchronize the photos in a symlink to another directory using the "FTP+Synchronization method".  I see output during the process that 1 album and "281 photos added to the database". 

How do I get those photos in to an album?

Offline

 

#6 2016-12-31 05:12:44

djnoah
Member
2016-12-30
15

Re: Add pictures from locally mounted drive

Okay I unchecked "perform a simulation only (nothing will be changed in the database)" and I see that I can add photos to a corresponding album name to the directory.

It works!  Thanks for the amazing software!

Offline

 

#7 2017-01-01 02:06:31

reddn
Member
DC, USA
2015-09-29
30

Re: Add pictures from locally mounted drive

You could also use site manager and add the path.  But that could create a permissions problem (I dont think so as it usually mounts drives readable to everyone).

Last edited by reddn (2017-01-01 02:12:21)

Offline

 

#8 2020-09-19 11:18:47

pitrou
Member
2020-09-19
1

Re: Add pictures from locally mounted drive

Let me share with you the solution I did put in place in case it can be of use for anyone else.

Problem statement
I have a local folder on my server (linux env) containing all my pictures that I want to  synchronize with Piwigo.
For different reasons, I'm not willing to move this folder under the piwigo/galleries/ sub-folder.
Also, this folder is accessed by users who create directories not necessarily respecting the Piwigo charset (see $conf['sync_chars_regex']). Even though this allowed charset can be changed, it can create issues downstream so I'm not willing to take the path of just creating a symlink and changing default sync charset in Piwigo.
So, my problem statement becomes the following: how can I replicate a similar folder structure as the one I have under my "Pictures" directory while respecting Piwigo's default sync charset?

Solution
I decided to create the following bash script which I've scheduled to run daily. This script goes through the original folder structure, replaces special characters from folders and files found by alpha numerical characters compliant with Piwigo's default sync charset (using sed) and creates symlinks to the original pictures.
Once done, it triggers a perl script (Piwigo Import Tree from Sebastien P.) calling Piwigo's web-services APIs to update Piwigo database.

Make sure to replace bold highlighted text and to run the script with a user having access to both folder structures

#!/bin/sh
log_piwigo=/path_to_your_log_location/piwigo_folder_structure_log.txt
origin=/path_to_your_pictures/Pictures
dest=/path_to_your_website_root/piwigo/galleries
http_user=http

echo "`date` - Starting mirroring process" > $log_piwigo

#Deletes existing folder structure in the piwigo/galleries folder if existing
echo "`date` - Deletes piwigo/galleries folder structure" >> $log_piwigo
find $dest/ ! -path $dest/ -type d | while read fullpath; do
    if [ -d "$fullpath" ]
    then
        rm -r "$fullpath" >> $log_piwigo
    fi
done

#Deletes potential remaining links in the piwigo/galleries folder
echo "`date` - Deletes remainings links if any" >> $log_piwigo
find $dest/ ! -path $dest/ -type l | while read fullpath; do
    if [ -L "$fullpath" ]
    then
        rm "$fullpath" >> $log_piwigo
    fi
done

#Mirrors folder structure from original Pictures folder with folders & files name compliant to $conf['sync_chars_regex']) charset
echo "`date` - Mirroring original folder structure with alpha-numerical characters" >> $log_piwigo
find -L $origin/ ! -path $origin/ | while read fullpath; do
    #strips off base path from full path
    subpath=${fullpath#$origin/}
    #Replaces all accented characters by non accented equivalents
    newpath=`echo $subpath | sed 'y/ âāáǎäàêēéěëèīíǐîìôōóǒöòûūúǔüùǖǘǚǜÂĀÄÁǍÀÊĒÉËĚÈÎĪÍÏǏÌÔŌÖÓǑÒÛŪÚÜǓÙǕǗǙǛ/_aaaaaaeeeeeeiiiiioooooouuuuuuüüüüAAAAAAEEEEEEIIIIIIOOOOOOUUUUUUÜÜÜÜ/'`;
    #Strips off special characters (@, [, ...) and makes sure final file/folder name meets default charset
    newpath=`echo $newpath | sed 's/[^a-zA-Z0-9\/-_.]//g' | sed 's/[!@#\$%^&*()]//g' | sed 's/[][]//g'`;
    newpath=$dest/$newpath
    if [ -d "$fullpath" ]
    then
        #echo "`date` - Creating folder $newpath" >> $log_piwigo
        mkdir "$newpath" >> $log_piwigo
    fi
    if [ -f "$fullpath" ]
    then
        #echo "`date` - Creating symlink $fullpath --> $newpath " >> $log_piwigo
        ln -s "$fullpath" "$newpath" >> $log_piwigo
    fi
done

echo "`date` - In case script is run by wrong username, change piwigo/galleries folder structure ownership to default httpd user" >> $log_piwigo
chown -R $http_user:$http_user $dest

echo "`date` - Triggers galleries refresh through "Piwigo Import tree" PERL script from Sebastien P." >> $log_piwigo
perl /path_to_script/piwigo_refresh.pl --base_url=https://path_to_your_website/piwigo --user=your_admin_user --password=your_admin_password --directory=$dest >> $log_piwigo

echo "`date` - End of mirroring process" >> $log_piwigo


Hope this helps!

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2021 · Contact