maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   (Automatic/one-tap) Photo upload to Owncloud (https://talk.maemo.org/showthread.php?t=94547)

bennypr0fane 2015-02-01 23:13

(Automatic/one-tap) Photo upload to Owncloud
 
Hi,
I'm trying to work out a procedure for the easiest possible way to automate upload of pictures taken with the Jolla to an Owncloud server.
We currently have no native application that can do it. What we do have is Rsync, and some powerful command line tools and Linux packages.
With Rsync and the ShellEx application, we can reduce the effort needed to upload all new pics to Owncloud to one tap.
What's stopping me right now is the problem: Where do I rsync to?
Webdav is the only recommended upload solution for OC besides sync clients/apps and the web interface.
Owncloud's webdav share needs to be mounted somewhere in order to have a target to rsync to.
We currently cannot mount the share on the phone itself, although we have davfs2 on Openrepos. It won't install on my Jolla because of a dependencies error (maybe NielDK can shed some more light on this issue).
If you have a root server that is always on and is not your Owncloud server, it should be easy for you to mount the OC webdav share there and rsync your Jolla pics to it.
However, I have only my OC machine with an open internet port, so I have to mount the webdav to that. It's not working for me though, so I was hoping you guys could help me work out the proper mount options for a share *on the server that it comes from*.
I have unsolved threads here and here.
I know this part is not exactly a Jolla/SailfishOS topic, but it's part of the procedure that we could use with the tools we have at our disposal already and post it on TJC as a wiki, once all the details are clear.
If I succeed to mount the share on the OC server and the channel is open, the next step could be some sort of daemon that monitors the folder where the camera saves the pics, and triggers the rsync command whenever a picture is taken. Suggestions for this are welcome.

pycage 2015-02-02 17:00

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Just a suggestion: You could rip out the WebDAV implementation from Cargo Dock and use that. It shouldn't be too dependent on the UI, if at all.

https://github.com/pycage/cargodock/...api/davapi.cpp

juiceme 2015-02-02 19:15

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459254)
If I succeed to mount the share on the OC server and the channel is open, the next step could be some sort of daemon that monitors the folder where the camera saves the pics, and triggers the rsync command whenever a picture is taken. Suggestions for this are welcome.

That part can be done really easy with pyinotify like in cloudsync.sh:
http://talk.maemo.org/showpost.php?p...61&postcount=8

bennypr0fane 2015-02-02 19:57

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by pycage (Post 1459333)
Just a suggestion: You could rip out the WebDAV implementation from Cargo Dock and use that. It shouldn't be too dependent on the UI, if at all.

https://github.com/pycage/cargodock/...api/davapi.cpp

At the moment this is read-only, it doesn't support uploads. At least that's the case for Cargo Dock. Unfortunately I don't have the skill set needed to find out whether or not it's true for just the Webdav part, nor for using that for anything else :-(
Maybe someone who does can try and take a look?

bennypr0fane 2015-02-02 20:01

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by juiceme (Post 1459346)
That part can be done really easy with pyinotify like in cloudsync.sh:
http://talk.maemo.org/showpost.php?p...61&postcount=8

great, that is in fact the kind of thing that I was thinking of. :cool: It's way more hacky though, someone should make it into a GUI app...

nieldk 2015-02-02 20:25

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459351)
great, that is in fact the kind of thing that I was thinking of. :cool: It's way more hacky though, someone should make it into a GUI app...

What dependency problem are you having with davfs2 on openrepos ? I just tried installing it again, and on my device it install fine without complains, did you enable my repository ?

juiceme 2015-02-02 21:03

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459351)
great, that is in fact the kind of thing that I was thinking of. :cool: It's way more hacky though, someone should make it into a GUI app...

Well what you want to do, is to make it a service that monitors your "/home/nemo/Pictures/Camera/" and automatically uploads anything when you snap a picture or take a video.

No need for any kind of GUI there.

[*] actually I am of a mind that less GUI-tweaking you need to do, the smarter your device is...

m4r0v3r 2015-02-02 22:16

Re: (Automatic/one-tap) Photo upload to Owncloud
 
can you have services on the Jolla? I thought it wasn't possible due to API restrictions and wakelocks?

juiceme 2015-02-03 04:54

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by m4r0v3r (Post 1459370)
can you have services on the Jolla? I thought it wasn't possible due to API restrictions and wakelocks?

Of course you can!
For example cron is one of most valuable things that I have in my device.

pycage 2015-02-03 18:50

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459349)
At the moment this is read-only, it doesn't support uploads. At least that's the case for Cargo Dock. Unfortunately I don't have the skill set needed to find out whether or not it's true for just the Webdav part, nor for using that for anything else :-(
Maybe someone who does can try and take a look?

The WebDAV implementation in Cargo Dock supports uploads to WebDAV.

bennypr0fane 2015-02-04 23:14

Re: (Automatic/one-tap) Photo upload to Owncloud
 
1 Attachment(s)
Quote:

Originally Posted by nieldk (Post 1459354)
What dependency problem are you having with davfs2 on openrepos ? I just tried installing it again, and on my device it install fine without complains, did you enable my repository ?

You said in the davfs for Jolla thread that it should suffice to also have OpenSSL installed, which I do, but I'm still getting this denpendency problem.
The main question though is, if I successfully install davfs on my Jolla, will that enable me to mount a Webdav share on the Jolla file system?

bennypr0fane 2015-02-04 23:35

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by pycage (Post 1459444)
The WebDAV implementation in Cargo Dock supports uploads to WebDAV.

Sorry, what I meant to say is that the CargoDock GUI currently does not have upload functionality, or more precisely, I can't find it. If it's there,
In any case, you also said that it's (at the moment?) not possible to rsync stuff to Owncloud through CargoDock.

bennypr0fane 2015-02-04 23:47

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by juiceme (Post 1459361)
Well what you want to do, is to make it a service that monitors your "/home/nemo/Pictures/Camera/" and automatically uploads anything when you snap a picture or take a video.

No need for any kind of GUI there.

[*] actually I am of a mind that less GUI-tweaking you need to do, the smarter your device is...

Well that certainly applies not just to you, but also dozens of other Jolla users who earn their living in the IT sector, right?
Not so much to people who don't know how to code, set up a server etc., or let's just say the average smartphone user. I actually keep forgetting that the average smartphone user will also never be an Owncloud user... :p
Me, I'm sort of somewhere inbetween these two categories, much closer to the latter one.
So tell me, how do you "make it a service"? :confused:

juiceme 2015-02-05 00:23

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459592)
Well that certainly applies not just to you, but also dozens of other Jolla users who earn their living in the IT sector, right?
Not so much to people who don't know how to code, set up a server etc., or let's just say the average smartphone user. I actually keep forgetting that the average smartphone user will also never be an Owncloud user... :p
Me, I'm sort of somewhere inbetween these two categories, much closer to the latter one.
So tell me, how do you "make it a service"? :confused:

Well, for starters; you can categorize applications broadly in 2 groups:
  • One kind is something that an user starts and uses. (browser, email, document-reader, ...)
  • Other kind is something that runs there "always" and users rarely know about it. (ofono, sshd, init, ...)

Fairly often there are cases that you have "both kinds work together" to make an useful functionality, for example the call recorder. It consists of 2 parts; one is a service always active and waiting for a call to happen and start recording, and the other is the user interface where you can change settings and listen to the recordings.

So. How to make an application a service? The first requirement is that it needs to run headless, meaning it should not need to display anything on the GUI nor require any direct user input when it strts and runs.
The next requirement is to launch it automatically, which on SFOS means it is started and stopped by systemd.

The details for this are usually hidden in the installation RPM package (but of course you can also do it manually)
In a simplified explanation; you create a small launcher script in /lib/systemd/system/ folder which tells what the service is and how to invoke it. There are quite a few service scripts there, you can look at them and see how they work.

The beautiful thing about packaging in linux (whether it be RPM or DEB or whatever) is that it is easy to create functionality that uses both services and UI components and it installs (and uninstalls) pretty much automatically without any need for the user to understand what happens under the hood. :)

nieldk 2015-02-05 05:49

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459590)
You said in the davfs for Jolla thread that it should suffice to also have OpenSSL installed, which I do, but I'm still getting this denpendency problem.
The main question though is, if I successfully install davfs on my Jolla, will that enable me to mount a Webdav share on the Jolla file system?

Hmm
Did you install my opened version from open reps?
I will update my packages later this week

bennypr0fane 2015-02-05 21:53

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by nieldk (Post 1459602)
Did you install my opened version from open reps?

Yes, is there any other version?

beidl 2015-02-08 14:01

Re: (Automatic/one-tap) Photo upload to Owncloud
 
I just came across this thread and wanted to chime in.
I'm the main developer of the (yes, yes, unofficial) ownCloud client for SailfishOS.
The client has been on the Jolla store for some time now but
2 months ago we got a nice little backup daemon running, which will be pushed to OpenRepos as soon as v0.3 is approved.
I should have advertised this earlier, but oh well.
So, if anybody is interested and can't wait until v0.3 hits the Jolla store (v0.3 is a pre-requisite for the daemon), you can grab the source from: https://github.com/beidl/harbour-owncloud
Note that building and running installs both the app and the daemon on the phone.

pycage 2015-02-08 16:28

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1459591)
Sorry, what I meant to say is that the CargoDock GUI currently does not have upload functionality, or more precisely, I can't find it. If it's there,
In any case, you also said that it's (at the moment?) not possible to rsync stuff to Owncloud through CargoDock.

You're right that there is no rsync support, because the filesystem is not mounted via a kernel filesystem driver.
That means, that the syncing would have to be implemented without rsync.

Anyway, uploading to OwnCloud with Cargo Dock is the same procedure as copying files locally. You have two panes. In one pane you open the source folder, in the other pane the destination folder (in this case on your OwnCloud). Tap and hold on a file in the source folder to get into selection mode and select what you want to upload. Then select "Copy" from the menu.
For downloading, do the same, just vice versa.

nieldk 2015-02-08 16:45

Re: (Automatic/one-tap) Photo upload to Owncloud
 
hmm

https://owncloud.org/faq/#rsync

"Why does ownCloud use csync rather than rsync?

rsync is a one-way syncing protocol. This means that if you have two servers and delete a file on one side, it will pop up again if you use rsync. To ensure old files get removed but new files added, and updated files overwritten, you need a N-to-N sync solution. ownCloud uses csync for syncing, which also deals with conflicts in a smart way."

bennypr0fane 2015-02-08 19:39

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by beidl (Post 1460078)
2 months ago we got a nice little backup daemon running

Could you elaborate on what the backup daemon does? What does it backup, and to where... Maybe a developer would understand what it is just by the words backup daemon, but a little explanation for the layman would be cool.

(btw: man, I can' t believe you actually call yrself that as a dev name)

bennypr0fane 2015-02-08 19:41

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by pycage (Post 1460089)
Anyway, uploading to OwnCloud with Cargo Dock is the same procedure as copying files locally. You have two panes. In one pane you open the source folder, in the other pane the destination folder (in this case on your OwnCloud). Tap and hold on a file in the source folder to get into selection mode and select what you want to upload. Then select "Copy" from the menu.
For downloading, do the same, just vice versa.

Alright, so that was the procedure that I was to dumb to discover for myself. I just looked for some menu item called "upload". That means you can also select multiple files for uploading in one go, right?

bennypr0fane 2015-02-08 19:54

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by nieldk (Post 1460090)
hmm
https://owncloud.org/faq/#rsync
"Why does ownCloud use csync rather than rsync?
rsync is a one-way syncing protocol. This means that if you have two servers and delete a file on one side, it will pop up again if you use rsync. To ensure old files get removed but new files added, and updated files overwritten, you need a N-to-N sync solution. ownCloud uses csync for syncing, which also deals with conflicts in a smart way."

The topic here though is not syncing, but uploading - more precisely, uploading pictures. Rsync is particularly suited for this task because it'll easily see what's already there and what's new and upload only the new stuff.
Of course it would be even more awesome to have a real two-way sync client like on the desktop - that's what I count on beidl's Owncloud app to do at some point in the future, with the ability to choose which folders to sync.
In this regard, I also sent you a question at openrepos whether you would consider porting the Unison command line to SFOS :-)
I'd still be happy to know the answer, but we could make that a separate thread.

bennypr0fane 2015-02-08 20:08

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane
Owncloud's webdav share needs to be mounted somewhere in order to have a target to rsync to. (..)
However, I have only my OC machine with an open internet port, so I have to mount the webdav to that. It's not working for me though, so I was hoping you guys could help me work out the proper mount options for a share *on the server that it comes from*.

Good news, this is accomplished - with davfs, after all. It seems like all the problems I've had trying to do it where not related to the mount point being on the same machine as the source of the share.
This means I already can rsync to it just by launching the command in ShellEx with one tap, and without even needing admin prvileges on the server.
Now for this part:

Quote:

Originally Posted by juiceme (Post 1459361)
Well what you want to do, is to make it a service that monitors your "/home/nemo/Pictures/Camera/" and automatically uploads anything when you snap a picture or take a video.
No need for any kind of GUI there.
[*] actually I am of a mind that less GUI-tweaking you need to do, the smarter your device is...

In that case, somebody should make it run under the hood :D
Any takers?

nieldk 2015-02-08 21:33

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Creating a service that monitors a folder and upload from that is easy.
This only takes a systemd service that executes a shell script using davfs to mount and upload any changes, no rocket science there.
Will have a look at it later

beidl 2015-02-09 16:00

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1460113)
Could you elaborate on what the backup daemon does? What does it backup, and to where... Maybe a developer would understand what it is just by the words backup daemon, but a little explanation for the layman would be cool.

(btw: man, I can' t believe you actually call yrself that as a dev name)

It's a background process that is started as part of starting the GUI shell (lipstick) using systemd.
This means that the process is launched when the device is booted up.
The nice thing about that is that this doesn't require the app to be running in the background.
The process watches for changes in ~/Pictures and uploads new files to a directory on the remote ownCloud instance (/Jolla/) when on WIFI.
Using the ownCloud app you can set credentials and the daemon will pick those settings.

(yeah, I know, I know. it's only funny when nobody has a clue what it means.... oida.)

cvp 2015-02-11 09:23

Re: (Automatic/one-tap) Photo upload to Owncloud
 
i want to use the auto sync with my owncloud server

- i install owncloud client from jolla store
- setup it right and can connect to my server
- i install than the ownCloud photo backup daemon
- than i activate the option in owncloud client "Camera photo backups"
- but nothing happend... i restart my phone, but this donst help too :(

do i need to setup a other setting? or do i have creat a folder on my owncloud server?

Phone is connected over wlan!

clovis86 2015-02-11 13:50

Re: (Automatic/one-tap) Photo upload to Owncloud
 
can't login anymore, saying wrong user/pwd :(
Even without daemon installed

http://reho.st/medium/self/f34ae9171...52a830265a.jpg

beidl 2015-02-12 13:44

Re: (Automatic/one-tap) Photo upload to Owncloud
 
You might want to try the newest versions of both the app and the daemon from OpenRepos.
I'll push a new version of the app to the Jolla store as soon as I get reports that the issues are fixed.

Also, the daemon creates the folder automatically, nothing special you'd have to set up. Only make sure that you enabled the daemon from within the app's settings.

bennypr0fane 2015-02-14 02:26

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by beidl (Post 1460078)
2 months ago we got a nice little backup daemon running, which will be pushed to OpenRepos as soon as v0.3 is approved.

So what do you use for syncing? If I already have most of the photos from the Jolla stored in Owncloud, will your daemon upload everything again and make lots of duplicates, or can it recognize identical files (even if it did not "personally" upload them)?
I just produced a heap of duplicates of about half the files in my Owncloud through a botched sync client setup - I'll test the daemon as soon I know that's not going to happen here.

beidl 2015-02-16 15:32

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by bennypr0fane (Post 1460738)
So what do you use for syncing? If I already have most of the photos from the Jolla stored in Owncloud, will your daemon upload everything again and make lots of duplicates, or can it recognize identical files (even if it did not "personally" upload them)?
I just produced a heap of duplicates of about half the files in my Owncloud through a botched sync client setup - I'll test the daemon as soon I know that's not going to happen here.

Internally the app & daemon use qwebdav, and there is no simple and bullet proof way to find duplicates (for example, via file hashes) from arbirtrary locations via the webdav protocol.
It would just upload your local ~/Pictures directory to the remote /Jolla directory. In case a remote file has the same name/relative path locally we assume that it was uploaded by the backup daemon and don't overwrite it.
After all, you usually don't edit pictures on the phone, when you "edit" them via the Gallery app it creates a new file and thats it.

billranton 2015-02-16 22:41

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Thanks for this daemon - it's very useful. Is there currently any way to configure the daemon, or do you plan to add any? I'd like to

- Enable/disable auto-upload
- Restrict auto-upload to Wi-fi only, forbid in 2G networks, disable when roaming
- Choose the owncloud folder to sync with

beidl 2015-02-18 01:11

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by billranton (Post 1460997)
Thanks for this daemon - it's very useful. Is there currently any way to configure the daemon, or do you plan to add any? I'd like to

- Enable/disable auto-upload
- Restrict auto-upload to Wi-fi only, forbid in 2G networks, disable when roaming
- Choose the owncloud folder to sync with

1) Already changeable from within the application settings
2) Already the case, upload only happens via WIFI
3) I could add UI to the settings for that, it certainly is easy to add.

EDIT; Also, credit where credit is due:
The initial daemon was provided by Sandsmark, I just fixed some issues like local->remote path matching,
generally improving reliability, memory footprint and I keep on maintaining it.

Manatus 2015-02-18 12:00

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by beidl (Post 1461097)
2) Already the case, upload only happens via WIFI

No, the daemon uploads via 3g connection. Not that I'm complaining; I like it better as I seldom bother to use WIFI, even at home.

EDIT: Double checked the version of owncloud client I'm using and that is from Openrepo's.

beidl 2015-02-18 16:47

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by Manatus (Post 1461130)
No, the daemon uploads via 3g connection. Not that I'm complaining; I like it better as I seldom bother to use WIFI, even at home.

EDIT: Double checked the version of owncloud client I'm using and that is from Openrepo's.

OK, this is odd as I just tested it again.
Yes, there was a bug related to uploading via mobile connection but I fixed it.
Care to do a bug report on GitHub and provide additional information?

Manatus 2015-02-18 17:20

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by beidl (Post 1461172)
OK, this is odd as I just tested it again.
Yes, there was a bug related to uploading via mobile connection but I fixed it.
Care to do a bug report on GitHub and provide additional information?

Yup, I'll create a bug report. Is there a log for harbour-owncloud-daemon or do I first kill it and start it on the command line?

Edit: Ok, I found logs under journalctl. I will attach those.

bennypr0fane 2015-02-23 18:12

Re: (Automatic/one-tap) Photo upload to Owncloud
 
Quote:

Originally Posted by beidl (Post 1460946)
Internally the app & daemon use qwebdav, and there is no simple and bullet proof way to find duplicates (for example, via file hashes) from arbirtrary locations via the webdav protocol.
It would just upload your local ~/Pictures directory to the remote /Jolla directory. In case a remote file has the same name/relative path locally we assume that it was uploaded by the backup daemon and don't overwrite it.
After all, you usually don't edit pictures on the phone, when you "edit" them via the Gallery app it creates a new file and thats it.

I already had a directory /Jolla in my Owncloud. The app created a directory /Camera under it, and proceeded to upload everything to /Jolla/Camera.
So that means that if a file with the same name is already present there, it won't be uploaded, but if e.g. I made subdirectories under /Jolla/Camera for each month and moved the photos in there, the daemon would assume that those files have not beem uploaded and do it again, yes?
This is an unsolved problem for me also with the Rsync approach, I believe it can't tell either if a file is present in a subdirectory of its target. However, I'd really like to organize those pictures - just having this loooooonnnnnngggggggg, ever growing list is really stupid...

Quote:

Originally Posted by beidl (Post 1461097)
1) Already changeable from within the application settings
2) Already the case, upload only happens via WIFI
3) I could add UI to the settings for that, it certainly is easy to add.

I actually would like to be able to upload over mobile data connection as well. Also customizing the upload dir, pleeze!

bennypr0fane 2015-02-28 13:01

Re: (Automatic/one-tap) Photo upload to Owncloud
 
It came to my mind that if the photos were already organized into subfolders at the source location of Rsync command, we could leave that as it is at the target and keep maintaining identical copies.
That way, we can still upload via Rsync without getting duplicates (That won't work if I want the photos organised at my target location, but they're all in one folder on the Jolla.).

I'm hoping that at some point the Jolla camera settings will include the option to automatically store all photos in subfolders by month.
However, until Jolla does make something of the kind, I guess we can still make it work with the tools at hand.

Surely there is a command (available on SailfishOS) that we could put together including some smart placeholders so that it'll always work with new files, moving everything into subfolders, one for each month?

As you surely understand by now, I don't have the skill to do that, so maybe some of the pros here can lend a hand?


All times are GMT. The time now is 06:40.

vBulletin® Version 3.8.8