Home » Projects » PhotoSync

Reza's PhotoSync

I noticed a few applications out there that simplify synchronization of photos from a PocketPC (Windows Mobile) phone to various sites -- either blogs or Flikr or something else proprietary. I like the functionality, but not the overhead of some of these large applications, and I didn't want to use someone else's photo repository so I wrote my own version.

The application will look for files in a directory that match a particular wildcard and post the data to any url you specify. It keeps track of the files it's uploaded by filename, and will persist configuration changes on powercycles. It can also be configured to autosync however often you choose it to, and to pop-up a notification when it's uploading a file. The application stays running even after you close the window, so it will operate in the background.

I have a simple perl script that I use to receive the data on my website, and the files are automatically put on my home page.



#!/usr/local/bin/perl

use CGI;
use Data::Dumper;

my $pass = 'somePassword';
my $targetDir = '/home/reza/public_html/cms/uploads/images/Cellphone/';
my $q = new CGI;

mreply("No file sent") unless ($q->param($pass));
my $fh = $q->upload($pass);
mreply("Error with transfer") if (!$fh && $q->cgi_error);
my $filename = $q->param($pass); $filename =~ s/[^A-Za-z0-9\.]//g;
mreply("File $filename already exists") if (-e "$targetDir/$filename");
open(OUT,">$targetDir/$filename") or mreply("Unable to create $targetDir/$filename : $!");
my ($buffer);
while(read($fh,$buffer,1024*10)) {
print OUT $buffer;
}
mreply("Transfer of $filename Sucessful!");

sub mreply {
print $q->header() . shift;
exit;
}

 

Installation

  1. Create some cgi to receive the data and put it online somplace. You can use my script above as an example.
  2. Download PhotoSync.exe and transfer it to your phone
  3. Run the application

Options Explained

Post URL - Specify the full url to the cgi where you will be uploading the images to

Sync Dir - The directory where the application looks for files

Password - The name under which the actual data is transfered. Your cgi needs to read the data from this variable.

User - The value associated with the variable 'user' which is also transfered to the cgi.

WildCard - This is the type of files that it should upload. Note that you dont have to limit yourself to just photos. Any file can be synced. Use '*' for all files.

AutoSync - Enable automatic synchrnoization of files, specify how often as well

Nofity When Uploading - Will pop up a notification when a file is being uploaded