script for eyefiserver on Linux machine

geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Mon, 2014-04-21 19:40

Hello,

I am using eyefi cards with a dedicated server on my network. I am able to load pictures from the card to the linux machine localy and quickly.

Now, I am looking for a script or command line to load each picture in a parent album.

Is there a easy way to do it?

I already checked a script from the project website without any success due to lack of doc.

Thanks in advance

Geoffroi

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2014-04-21 19:49
 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Mon, 2014-04-21 19:59

Hello Dave,

I am looking for a solution "on demand". When I take a picture, my camera with the eyefi send the file to a server. That server is able to run a script or whatever.

Till now I tried gal3upload but it load each picture several times.

Do you know if I can execute a command line with REST which include the upload key, pid key and my picture file?

Regards

Geoffroi

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2014-04-21 21:56

http://code.google.com/p/gal3upload/

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Mon, 2014-04-21 23:44

Hello Dave,

Thanks for the answers.

Unfortunately, gal3upload load files several time and is not able to help my with that.

Is there a doc or sample files to use REST API and/or Rest module?

I only want to upload one file each time I run a "script" with url, pid, key and my picture (directory/filename).

Regards

Geoffroi

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2014-04-22 00:46

http://codex.galleryproject.org/Gallery3:API:REST

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Tue, 2014-04-22 07:57

Hello Dave,

I found something written in perl

http://codex.galleryproject.org/Gallery3:API:REST:perl

But, I need someone who knows how to us this script.

Which parametres must I put to upload a file?

I tried that_perl_script.pl url key pid file_to_upload without success.

Thanks a lot.

Geoffroi

 
spags

Joined: 2010-03-26
Posts: 120
Posted: Tue, 2014-04-22 12:54

Sorry, never used REST. But there is a ton of information at http://codex.galleryproject.org/Gallery3:API:REST and upload example at http://codex.galleryproject.org/Gallery3:API:REST:Examples that could probably get you started.

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Wed, 2014-04-23 12:59

Thank you for your answer,

Unfortunately, I am not used to develop nor reverse engineer tools, I only use them (tools + manual, I know howto do things). With these links I am not able to do anything.

What is that syntax, is it an HTTP code or C#? We do not know (except for guys how used to use this) which language is it. With the language I can try to translate things but only with code, I can not.

That's why I am asking to the one who write the perl script to provide doc or informations in order to use it. To me it is more easy to handle things with manual. Isn't it?

So I plane to write a doc in order to provide a way to install an autonomous eyefi server with Gallery integration but now, I am locked with the integration into Gallery.

Camera -> EyeFi card ---> LAN (Local Network without Internet) ---> Eyefi server on a Linux Machine -> Script to put pictures into Gallery -> Online pictures sort by date in an unique album or in an album named by date. For the moment, I have 2/3 of the beginning of the project and the last part OK. I still have to "write" the script and everything will be done.

Regards

Geoffroi

 
spags

Joined: 2010-03-26
Posts: 120
Posted: Wed, 2014-04-23 20:34

Oh well in that case, check out my Calendar Import module. It still isn't "on demand" and it will only go as far as creating monthly albums (sounds like you are after daily albums) but it will get you a step closer to what you are looking for. Plenty of documentation as well.

Presumably you can configure your camera to dump images to an ftp share (or something) and then let Calendar Import perform the importing from there. The images will be imported into a series of sub-albums rather than a single album.

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Wed, 2014-04-23 20:40

Hello Spags and "the others",

I reversed the perl script! now it seems OK, I still have to work a lot but I was able to load 1 pictures by command line.

Stay tuned.

Geoffroi

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Wed, 2014-04-23 23:59

Ok,

It is late but it works.

Thanks

Geoffroi

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Thu, 2014-04-24 02:16

Looking forward to you to provide documentation or information on order to use it.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Thu, 2014-04-24 08:07

Hello Dave,

For sure! I gonna write something asap to participate a little bit to the project and help the community.

Now, my process is easy between the camera and Internet. I have to find a solution to improve efficiency but it works.

When I take a picture, it is loaded to the Linux machine through eyefi cards + eyefiserver (from Jeff Tchang, thanks to him) on a LAN (that point is important). And then the server run a script to convert NEF to jpg and through ufraw command line. After while, the perl script load each picture into the gallery (now, I put all pictures in the same album. Ideally, I gonna develop it to create an album by date because the system is also able to gather pictures not yet downloaded).

Stay tuned

Geoffroi

 
geoffroi

Joined: 2014-04-17
Posts: 9
Posted: Sat, 2014-04-26 10:11

Ok,

First of all the script tuned by myself (note, in perl, arguments from the command line use the name ARGV[x] x start from 0. In my script, the upload key is ARGV[0])

_______________________________________________________________________________________
#!/usr/bin/perl

# This is a Gallery3:API:REST:perl tuned to works on my Debian server under the name g3upload.pl
# I provide it AS IS.
# don't forget the right to execute your script chmod +x....
# put the script where you want but maintain your OS clean ;o) /usr/local/bin is a good place to put it.
# So, now you want to know howto use it, isn't it?
# run that command : perl g3upload.pl "your_upload_key" "http://your_gallery_server/gallery3/index.php/rest/item/your_parent_ALBUM" "photo" "\the\full\path\to\your\JPEG" "filename"
# your_upload_key is the key to bypass authentication on Gallery3
# http://your_gallery_server/gallery3/index.php/rest/item/your_parent_ALBUM is the URL to the ALBUM you want to use to load pictures [by default, you can use 1. Pictures will appear in the root Galley]
# "photo" because you want upload pictures, but gallery allow you to upload something else
# "\the\full\path\to\your\JPEG" this is the URI where is your picture
# "filename" is the name displayed by gallery for that item
# Enjoy it!

use JSON;
use LWP::UserAgent;
use HTTP::Headers;
use HTTP::Request;

{
my($key, $parent, $filetype, $fileLocation, $filename, $title, $description, $tags) = @ARGV;
my $entity = {
name => $filename,
type => $filetype
};

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks) = stat($fileLocation);

open(IMAGE,"$fileLocation") || die "open: $!";
my $item;
my $nread = sysread(IMAGE,$item,$size);
close(IMAGE);

my $boundary = "gallery3.upload.$$";

my $json = JSON->new;
my $json_entity = $json->encode($entity);

my(@parts);
push(@parts,"--$boundary");
push(@parts,'Content-Disposition: form-data; name="entity"');
push(@parts,'Content-Type: text/plain; charset=UTF-8');
push(@parts,'Content-Transfer-Encoding: 8bit');
push(@parts,"");
push(@parts,$json_entity);

push(@parts,"--$boundary");
push(@parts,'Content-Disposition: form-data; name="file"; filename="'.$filename.'"');

# G3 rest server only wants application/octet-stream, won't accept real mime type
push(@parts,'Content-Type: application/octet-stream');

# G3 rest server only wants binary, won't parse base64
push(@parts,'Content-Transfer-Encoding: binary');
push(@parts,'');
push(@parts,$item);
push(@parts,"--$boundary--");

my $data = join("\n",@parts);

my $ua = LWP::UserAgent->new;

my $headers = HTTP::Headers->new;
$headers->header('X-Gallery-Request-Method' => 'post');
$headers->header('X-Gallery-Request-Key' => $key);
$headers->header('Content-Type' => "multipart/form-data; boundary=$boundary");
$headers->header('Content-Length' => length $data);

my $request= HTTP::Request->new('POST',$parent,$headers,$data);
my $result = $ua->request($request);

$result->content;
}
_____________________________________________________________________________________________________________________

That's it.

With that script I can enjoy my pictures on Internet only by taking them

Regards

Geoffroi