MantisBT - Piwigo
View Issue Details
0001051Piwigoweb APIpublic2009.07.14 22:192009.11.23 01:15
plg 
plg 
normalfeatureN/A
closedfixed 
2.0.3 
2.0.42.0.7 
any
Apache 1.3.x
0001051: upload photo more than once
On topic:15172, we have discussed about the ability in pLoader to re-upload a photo. To add the high resolution or because the resizing settings have changed.

plg wrote:

> OK, interesting improvement. First Piwigo identifies the photo, then Piwigo
> compares the md5sum of each file (3 files come with a md5sum to check that
> upload was successful). If the md5sum differs, the file is overwritten.

ron wrote:

> Current API pwg.images.exist uses the original photo md5 checksum. I agree
> that it should also take thumbnail and resized md5 checksum as parameters. It
> should return which md5 is different in order to tell to pLoader which file
> has to be sent.


At least pwg.images.exist and pwg.images.add must be changed to handle this feature request.
No tags attached.
related to 0001052resolved rosman pLoader support photo re-upload 
Issue History
2009.07.14 22:19plgNew Issue
2009.07.14 22:19plgStatusnew => assigned
2009.07.14 22:19plgAssigned To => plg
2009.07.14 22:19plgbrowser => any
2009.07.14 22:19plgWeb server => Apache 1.3.x
2009.07.14 22:21plgRelationship addedrelated to 0001052
2009.11.20 22:19svnCheckin
2009.11.20 22:19svnNote Added: 0003098
2009.11.22 23:09svnCheckin
2009.11.22 23:09svnNote Added: 0003107
2009.11.23 00:38svnCheckin
2009.11.23 00:38svnNote Added: 0003108
2009.11.23 00:57svnCheckin
2009.11.23 00:57svnNote Added: 0003109
2009.11.23 00:58svnCheckin
2009.11.23 00:58svnNote Added: 0003110
2009.11.23 00:59svnCheckin
2009.11.23 00:59svnNote Added: 0003111
2009.11.23 01:06plgNote Added: 0003112
2009.11.23 01:15plgStatusassigned => closed
2009.11.23 01:15plgResolutionopen => fixed
2009.11.23 01:15plgFixed in Version => 2.0.7

Notes
(0003098)
svn   
2009.11.20 22:19   
[Subversion] r4328 by plg on branch 2.0

-----[Subversion commit log]----------------------------------------------------
improvement: to prepare feature 1051, the code to add a single file (works for
the 3 picture types, ie thumb/file/high) has been factorized into a single
add_file function.

bug fixed: when a function not directly called by the API (such as merge_chunks
or the new add_file function) returning a PwgError, it was not stopping the
execution, it just sets the error code/message. Now we don't return PwgError,
we only create one and then exit().
(0003107)
svn   
2009.11.22 23:09   
[Subversion] r4344 by plg on branch 2.0

-----[Subversion commit log]----------------------------------------------------
feature 1051: new API method pwg.images.checkFiles. This method will be useful
before asking for an update on photo files.

Enhancement in code factorization.
(0003108)
svn   
2009.11.23 00:38   
[Subversion] r4345 by plg on branch 2.0

-----[Subversion commit log]----------------------------------------------------
feature 1051: ability to add/update a file for an existing photo. For example,
you can add the "high" later. Another example is to update the "web resized"
file (new dimensions is a common example). It also works for thumbnails.
Updating an existing file has no impact on the logical level (list of tags,
list of categories, title, description and so on).
(0003109)
svn   
2009.11.23 00:57   
[Subversion] r4346 by plg on trunk

-----[Subversion commit log]----------------------------------------------------
merge r4328 from branch 2.0 to trunk

improvement: to prepare feature 1051, the code to add a single file (works for
the 3 picture types, ie thumb/file/high) has been factorized into a single
add_file function.

bug fixed: when a function not directly called by the API (such as merge_chunks
or the new add_file function) returning a PwgError, it was not stopping the
execution, it just sets the error code/message. Now we don't return PwgError,
we only create one and then exit().
(0003110)
svn   
2009.11.23 00:58   
[Subversion] r4347 by plg on trunk

-----[Subversion commit log]----------------------------------------------------
merge r4344 from branch 2.0 to trunk

feature 1051: new API method pwg.images.checkFiles. This method will be useful
before asking for an update on photo files.

Enhancement in code factorization.
(0003111)
svn   
2009.11.23 00:59   
[Subversion] r4348 by plg on trunk

-----[Subversion commit log]----------------------------------------------------
merge r4345 from branch 2.0 to trunk

feature 1051: ability to add/update a file for an existing photo. For example,
you can add the "high" later. Another example is to update the "web resized"
file (new dimensions is a common example). It also works for thumbnails.
Updating an existing file has no impact on the logical level (list of tags,
list of categories, title, description and so on).
(0003112)
plg   
2009.11.23 01:06   
So, here comes the HOWTO. I've added pwg.images.checkFiles and pwg.images.addFile actions.

As the self decsription for pwg.images.checkFiles says:

> check if you have updated version of your files for a given photo,
> for each requested file type, the answer can be "missing", "equals"
> or "differs"

The pwg.images.addFile can be called without using pwg.images.checkFiles before, by default the files are overwritten, so you can overwrite a file with the same file, it's just stupid :-) so please, to avoid bandwidth load, check before sending data on the network!

pwg.images.addFile is a light weight pwg.images.add : no logical info, single file. You have to tell which file type you're sending amon thumbnail/file/high. You must have sent data with pwg.images.addChunk before. pwg.images.addFile "only" perform checks, a call to merge_chunks and a database update if required.

Of course, tools/piwigo_remote.pl has been updated to give a real example of how to use these new web API methods.