šŸ•¹ļø Do Something Great! šŸ˜„

Tag: dropbox

  • Upload and converting pictures automatically from Dropbox

    I’ve been using Pelican to publish this website for awhile now, and one of the things I wanted to do was to be able to post from my phone and include pictures. To accomplish this I wrote a script that checks the upload folder in dropbox, and if there is a file, it will re-size the pictures to 4 different sizes and upload it to Amazon S3. I can then easily link to any of the sizes of pictures for my posts.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    #!/bin/bash
    
    TOUPLOAD=/Path/to/check/for/pics/*
    SAVEUPLOADED=/Path/to/save/uploaded/pics
    S3BUCKET="BUCKET/for/pics"
    S3CMD=/usr/local/bin/s3cmd
    DIR=/Path/to/html/file/that/has/links/to/pics
    UPLOADED=FALSE
    
    
    if [[ ! -d /tmp/uploadpic ]]; then
        mkdir /tmp/uploadpic
    fi
    
    if [[ ! -d ${UPLOADED} ]]; then
        mkdir -p ${UPLOADED}
    fi
    
    shopt -s nullglob
    
    for f in ${TOUPLOAD}
    do
        if [[ -f ${f} ]]; then
        OUT=/tmp/uploadpic
        FILENAME=${f}
        FULLFILENAME=$(basename "${f}")
        EXT=${FULLFILENAME##*.}
        FILE=${FULLFILENAME%.*}
    
        echo "Working with ${FILE}.${EXT}"
    
        echo "Resizing"
        convert "${FILENAME}" -resize 320x240 "${OUT}/${FILE}-xs.${EXT}"
        convert "${FILENAME}" -resize 640x480 "${OUT}/${FILE}-s.${EXT}"
        convert "${FILENAME}" -resize 800x600 "${OUT}/${FILE}-m.${EXT}"
        convert "${FILENAME}" -resize 1024x768 "${OUT}/${FILE}-l.${EXT}"
        convert "${FILENAME}" -resize 2048x1024 "${OUT}/${FILE}-x.${EXT}"
    
        echo "Uploading"
    
        find ${OUT} -name "${FILE}*" -print0 | xargs -0 -I upload ${S3CMD} put upload s3://${S3BUCKET}/ --acl-public
    
        ${S3CMD} put "${FILENAME}" s3://${S3BUCKET}/ --acl-public
        mv "${FILENAME}" ${SAVEUPLOADED}/
        UPLOADED=TRUE
    fi
    done
    
    if [[ ${UPLOADED} = TRUE ]]; then
        echo "Pics have been uploaded..."
        echo "<html><head><title>Blog Pics</title></head><body><ul>" > ${DIR}
        ${S3CMD} ls s3://${S3BUCKET}/ | sort -r | cut -c 69- | xargs -I filename echo "<li><a href='http://${S3BUCKET}/filename'>filename</a>" >> ${DIR}
        echo "</ul></body></html>" >> ${DIR}
    fi
    

    This requires ImageMagick to be installed for the convert command. Once I have the script written I set up crontab to run the script every minute.

  • Dropbox in the paperless classroom

    Dropbox Organization Tips for Teachers and the Paperless Classroom

    Dropbox is an essential for me. I like apps that link with Dropbox in every way and it is an essential part of my paperless routine with my students. This past Sunday at #txeduchat I was asked some specific questions about how I use Dropbox to take my classroom as paperless as possible, so I thought Iā€™d make it my app of the week and teach you some things that might be helpful.

    And if you are a Google Apps for Education school, most of these tips can apply directly to Google Drive.

  • Can Insync dethrone Dropbox as a cloud storage service?

    A couple of weeks ago I read a Techcrunch article about Insync.
    It is a service that works almost identically to Dropbox. Their
    differentiating feature is the fact that they use your Google Docs
    account for storage. A downside to this is that you only have 1GB of
    storage with normal accounts, but Google lets you add 20GB to that for
    \$5 a year (compared to Dropbox costing \$10 a month for 50GB of space).

    To set up, you download the client, install it, and log into your Google
    account or accounts. It lets you sync multiple Google accounts at the
    same time, so I can use it with my work Google account, my professional
    Google account, and my personal Google account. Insync creates a folder
    in your home directory called Insync, and creates a folder for each one
    of your accounts inside of it. Google Docs files show up as their
    Microsoft Office equivilents.

    It works really well, just as well as Dropbox. There are a few
    annoyances, such as the inability to pause syncing (for example, if
    you?re on slow connection), but for the price it?s hard for Dropbox to
    beat.

    One tip I would recommend is to create a folder inside your Google
    account folder and use that like you would use a Dropbox account. If
    your Google Docs account is anything like mine, you have a ton of files
    and very little organization. Since I?m using this basically as a
    Dropbox replacement, I created a folder called DesktopSync, and I use
    that like I would use my Dropbox.

    If you are in a Google Apps for Education school district, your Google
    accounts work fine with Insync. I haven?t tested it on our client
    computers that students use yet. If it works there, it would be a very
    nice solution to file access outside of the district.