Tuesday, May 02, 2017

3Shrinking Files on Android: From Photo to 3 Digit Code in 2 Clicks

I recently added the ability 3shrink content that has no URL, such as a photo, PDF or sound clip. I was itching to get this working on Android, and here's why. Consider this sketch:

It seems reasonable that I'd want to associate a photo of the scene so I could compare them later. After sketching the scene I snapped a photo and used the new 3shrink capability to automatically turn it into a code. I then scribbled the code on the photo, QU3. At a future date, I can visit: http://benjisimon.3shrink.com/qu3 and see my the photo that inspired this sketch:

In other words, I now the ability to seamlessly go from a photo to a 3 digit code on my Android device.

To make this functional, I needed to enhance the AutoShare'ing 3shrink solution I previously created. The first step was to enhance the top level 3shrink Tasker action:

I've added a new leading 'If' condition that checks to see if %asfile1 is set. If it is, then I know that the AutoShare command was invoked with at least one file. %asfile1 contains a full path to the file, which is exactly what I need later on in the process.

I then updated the low level 3shrink action to check to see if the content being shared is a file that exists:

If it is, I do a Tasker HTTP POST of the content. One gotcha I found with the HTTP POST is that %HTTPD doesn't appear to be set. I overcame this by storing the result of the POST in a text file and then reading that text file into a variable. Incidentally, the content returned by the POST is the 3 letter code that corresponds to this file.

And that's pretty much all there is to it. I snap a photo, hit the share button and a few moments later, I see my magic code:

See the original photos over at http://blogbyben.3shrink.com/ck4.

No comments:

Post a Comment