LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Introducing LiteCloud
#4
(02-03-2015, 06:22 PM)Wirezfree link Wrote: Hi Jerry,

I maybe interested, I have a SugarSync Account that I used to use with Windows.
Which was great, just right click any file/folder, add to Sugarsync for it to Synch to the Cloud.
Then Files?Folders auto sync'd as soon as you did a save or change.

I need to see if the Linux OwnCloud app does the same.?

Yup, I can provide a simple to use script, credit - https://github.com/schiesbn/shareLinkCreator

First do: sudo apt-get install xclip

Create a new file, call it litecloudupload, place the following inside:

Code:
#!/bin/bash
#
# Public Link Creator Version 1.0
#
# (c) Copyright 2013 Bjoern Schiessle <[email protected]>
# Modified for LiteCloud by Jerry Bezencon
#
# This program is free software released under the MIT License, for more details
# see LICENSE.txt or http://opensource.org/licenses/MIT
#
# Description:
#
# The program was developed for the Thunar file manager but it should also
# works with other file managers which provide similar possibilities to
# integrate shell scripts. For example I got some feedback that it also works
# nicely with Dolphin and Nautilus.
#
# This script can be integrated in the Thunar file manager as a "custom
# action". If you configure the "custom action" in Thunar, make sure to pass
# the paths of all selected files to the program using the "%F" parameter. The
# program expects the absolute path to the files. Once the custom action is
# configured you can execute the program from the right-click context menu. The
# program works for all file types and also for directories. Once the script
# gets executed it will first upload the files/directories to your ownCloud and
# afterwards it will generate a public link to access them. The link will be
# copied directly to your clipboard and a dialog will inform you about the
# URL. If you uploaded a single file or directory than the file/directory will
# be created directly below your "uploadTarget" as defined below. If you
# selected multiple files, than the programm will group them together in a
# directory named with the current timestamp.
#
# Before you can use the program you need to adjust at least the "baseURL",
# "username" and "password" config parameter below. If you keep "username"
# and/or "password" empty a dialog will show up and ask for the credentials.
#
# Requirements:
#
# - curl
# - xclip
# - zenity

# config parameters
baseURL="http://hostsiteaddress/owncloud"
uploadTarget=""
username="bob"
password="bobspassword"
# if you use a self signed ssl cert you can specify here the path to your root
# certificate
cacert=""

# constants
TRUE=0
FALSE=1

webdavURL="$baseURL/remote.php/webdav"
url=$(echo "$webdavURL/$uploadTarget" | sed 's/\ /%20/g')
shareAPI="$baseURL/ocs/v1.php/apps/files_sharing/api/v1/shares"
curlOpts=""
if [ -n "$cacert" ]; then
    curlOpts="$curlOpts --cacert $cacert"
fi

# check if base dir for file upload exists
baseDirExists() {
    if curl -u "$username":"$password" --output /dev/null $curlOpts --silent --head --fail "$url"; then
        return $FALSE
    fi
    return $TRUE
}

checkCredentials() {
    curl -u "$username":"$password" $curlOpts --output /dev/null --silent --fail "$webdavURL"
    if [ $? != 0 ]; then
        zenity --error --title="LiteCloud Upload" --text="Username or password does not match"
        exit 1
    fi
}

# upload files, first parameter will be the upload target from the second
# parameter on we have the list of files
uploadFiles() {
    for filePath in "${@:2}"
    do
        basename=$(basename "$filePath")
        basename=$(echo "$basename" | sed 's/\ /%20/g')
        if [ -f "$filePath" ]; then
            curl -u "$username":"$password" $curlOpts -T "$filePath" "$1/$basename"
            count=$(($count+1))
            echo $(($count*100/$numOfFiles)) >&3;
        else
            curl -u "$username":"$password" $curlOpts -X MKCOL "$1/$basename"
            uploadDirectory "$1/$basename" "$filePath"
        fi
    done
    return $TRUE
}

# upload a directory recursively, first parameter contains the upload target
# and the second parameter contains the path to the local directory
uploadDirectory() {
    while read filePath; do
        filePath=$(basename "$filePath")
        urlencodedFilePath=$(echo "$filePath" | sed 's/\ /%20/g')
        if [ -d "$2/$filePath" ]; then
            curl -u "$username":"$password" $curlOpts -X MKCOL "$1/$urlencodedFilePath"
            uploadDirectory "$1/$urlencodedFilePath" "$2/$filePath"
        else
            curl -u "$username":"$password" $curlOpts -T "$2/$filePath" "$1/$urlencodedFilePath"
            count=$(($count+1))
            echo $(($count*100/$numOfFiles)) >&3;
        fi
    done < <(find "$2" -mindepth 1 -maxdepth 1)

}

# create public link share, first parameter contains the path of the shared file/folder
createShare() {
    result=$(curl -u "$username":"$password" $curlOpts --silent "$shareAPI" -d path="$1" -d shareType=3)
    shareLink=$(echo $result | sed -e 's/.*<url>\(.*\)<\/url>.*/\1/')
    shareLink=$(echo $shareLink | sed 's/\&amp;/\&/')
    echo $shareLink | xclip -sel clip
    return $TRUE

}

# if no username/password is set in the script we ask the user to enter them
askForPassword() {
    ENTRY=`zenity --password --username --title="LiteCloud Upload"`

    case $? in
        0)
        username=`echo $ENTRY | cut -d'|' -f1`
        password=`echo $ENTRY | cut -d'|' -f2`
        ;;
        1)
            exit 0;;
        -1)
            exit 1;;
    esac
}

if [ -z $password ] || [ -z $username ]; then
    askForPassword
fi

checkCredentials

exec 3> >(zenity --progress --title="LiteCloud Upload" --text="Uploading files and generating a public link" --auto-kill --auto-close --percentage=0 --width=400)

numOfFiles=$(find "$@" -type f | wc -l)
count=0

if baseDirExists; then
    curl -u "$username":"$password" $curlOpts -X MKCOL "$url"
fi

# if we have more than one file selected we create a folder with
# the current timestamp
if [ $# -gt 1 ]; then
    share=$(date +%s)
    url="$url/$share"
    curl -u "$username":"$password" $curlOpts -X MKCOL "$url"
elif [ $# -eq 1 ]; then
    share=$(basename "$1")
else
    zenity --error --title="LiteCloud Upload" --text="no file was selected!"
    exit 1
fi

if uploadFiles $url "$@"; then
    createShare "/$uploadTarget/$share"
fi

output="File uploaded successfully. Following public link was generated and copied to your clipboard: $shareLink"
zenity --info --title="LiteCloud Upload" --text="$output" --no-markup

Explanations of the config parameters:

# config parameters
baseURL="http://hostsiteaddress/owncloud" // website address
uploadTarget="" // leave as is and all files will go into your main LiteCloud directory, or you can specify a folder like 'photos'
username="bob" // leave the username and password blank to be prompted for it each time
password="bobspassword" // see username description

Right click on it, make it executable.

Then create a custom Thunar action with the following:

Point to your script eg. /home/bob/scripts/litecloudupload %F, choose an icon you like:
(For added Security, I'd recommend you put this script in /root on your pc, and set the Command to: gksudo /root/litecloudupload %F)

[Image: tv8rFiN.png]

Tick all boxes on Appearance conditions:

[Image: k8BFujY.png]

Bingo Smile

[Image: YJLiPqJ.png]

Client in the tray on Linux Lite:

[Image: 3Etaub7.png]
Reply


Messages In This Thread
Introducing LiteCloud - by Valtam - 02-03-2015, 06:40 AM
Re: Introducing LiteCloud - by Scott(0) - 02-03-2015, 03:42 PM
Re: Introducing LiteCloud - by Wirezfree - 02-03-2015, 06:22 PM
Re: Introducing LiteCloud - by Valtam - 02-03-2015, 07:51 PM
Re: Introducing LiteCloud - by Wirezfree - 02-03-2015, 11:02 PM
Re: Introducing LiteCloud - by Valtam - 02-03-2015, 11:09 PM
Re: Introducing LiteCloud - by Wirezfree - 02-03-2015, 11:33 PM
Re: Introducing LiteCloud - by N4RPS - 02-05-2015, 01:19 PM
Re: Introducing LiteCloud - by preecher - 02-27-2015, 06:37 AM
Re: Introducing LiteCloud - by Valtam - 02-27-2015, 06:51 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)