mobilepickphoto file type and ftp

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

mobilepickphoto file type and ftp

Post by cusingerBUSCw5N » Mon Oct 08, 2012 3:50 am

I want to ftp a photo taken on an andoid to an outside server.

Code: Select all

  if the environment = "mobile" then
set the name of the templateimage to "harry"
set the loc of the templateimage to 400,100 -- or wherever you want it

mobilePickPhoto "camera" ,400 , 400
if the result = "" then 
-- ok do something with image "harry" here
      set the width of image "harry" to 400
      set the height of image "harry" to 400
      set the top of image "harry" to 400
      set the left of image "harry" to 100
set the border  of image "harry" to  true
set the threeD of image "harry" to false
set the borderwidth of image "harry" to  1
set the locklocation of the templateImage to false
set vis of image "harry" to "true"

 constant FTPHOST = "xxxxxx"
   constant FTPUSER = "xxxxx"
   constant FTPPASS = "xxxxx"

export image "harry" to pictVariable as png

   put pictVariable into url ("ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST&"/path_to_docs_file/docs/myvar.png" )

end if
end if
It doesn't work. I have succeeded in getting empty files - so the ftp part is OK. I tried it without using the export an image line - and it failed as well. I have tried put image (1) instead of put pictVariable - and it failed....

1) How do you take a picture and ftp it to a remote site?

2) If the picture is already saved in the android's photo gallery - how do you get the file name and ftp it?

Thank you.

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: mobilepickphoto file type and ftp

Post by cusingerBUSCw5N » Mon Oct 08, 2012 4:21 am

I have succeeded in saving my photo on the android, using

export snapshot from image "harry" to file ("/sdcard/Pictures/foo1.png") as png

(I might change it to /sdcard/pictures/screenshots/foo1.png)....

Anyway...I still can't figure out how to ftp it directly, or get an existing image (in this case foo1.png) and ftp it.

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: mobilepickphoto file type and ftp

Post by cusingerBUSCw5N » Mon Oct 08, 2012 6:15 pm

I have partially succeeded in ftp'ing from an android to a server with this code

Code: Select all

on mouseUp

      constant FTPHOST = "xxxxx"
   constant FTPUSER = "xxxx"
   constant FTPPASS = "xxxxx"   

 put ("/sdcard/Pictures/foo1.png") into myGalleryFile 
          
put url("file:"&myGalleryFile) into url ("ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST&"/path_to_mydocs_on_my_server/mytest.png" )
end mouseUp
I get a file mytest.png with 271 KB. It claims it is a png file type - but if I try opening it in a graphics program it says won't open "not a valid png" If I try clicking on it - "the file is corrupt, too large..."

cusingerBUSCw5N
Posts: 339
Joined: Wed Jul 11, 2012 9:24 pm

Re: mobilepickphoto file type and ftp

Post by cusingerBUSCw5N » Tue Oct 16, 2012 3:30 pm

OK. so the solution, provided through another post is to use binfile. Works like a charm. It is still a bit slow - initially shows up as 0 size, but if you wait a minute or so, it comes through.


put url("binfile:"&myGalleryFile) into url ("ftp://" & FTPUSER & ":" & FTPPASS & "@" & FTPHOST&"/path_to_folder/" &tFileName)

qberty1337
Posts: 35
Joined: Sun Sep 09, 2012 1:09 pm

Re: mobilepickphoto file type and ftp

Post by qberty1337 » Sun Oct 21, 2012 3:27 pm

Keep in mind that you should ONLY use binfile for...binary files (who would have thought?). Images, music, encrypted documents, software. NOT text files, or ANYTHING that contains plaintext. Binfile is slower then file, for a good reason too.

It's also not a good idea to FTP from Android. At least not yet. If you can find a way to secure your account information, then it'd be okay.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: mobilepickphoto file type and ftp

Post by Mark » Sun Oct 21, 2012 4:51 pm

Hi,

To avoid confusion, I'd like to remark that there are many situations in which you'd want to use binfile for text files. Basically, use binfile whenever you don't want ASCII 13 to be converted to ASCII 10. I don't think that "binfile" is slower than "file".

If you are concerned about the security of your login data, then FTP is never a good idea. Whether you're using a desktop PC or Mac, an iOS device or an Android is irrelevant.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

qberty1337
Posts: 35
Joined: Sun Sep 09, 2012 1:09 pm

Re: mobilepickphoto file type and ftp

Post by qberty1337 » Tue Oct 23, 2012 2:33 am

Actually, using FTP straight from Android IS different then through the PC or Mac. THe coding may be the same, but the security on how outbound connections take place on an android device is extremely different.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: mobilepickphoto file type and ftp

Post by jacque » Tue Oct 23, 2012 6:06 am

Now I'm curious. Different how? I thought ftp was always plaintext regardless of platform.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

qberty1337
Posts: 35
Joined: Sun Sep 09, 2012 1:09 pm

Re: mobilepickphoto file type and ftp

Post by qberty1337 » Tue Oct 23, 2012 8:38 am

Well usually anyone that deals with android kernels and custom ROMs, you tend to find out things you haven't actually thought about.

For Android, at the moment, outbound connections are a security risk. A major one depending on your ISP/Carrier.

A lot of popular Carriers put their own proprietary software bundled into the phone, as well as some others like to replace bigger parts of Androids system (HTC - Sense, Samsung - TouchWiz, Motorola - Motoblur etc..) A lot of these "versions" of Android have various data collection services running in the background. As FTPeS/Se are not support yet on Android, it wouldn't be wise to play with valuable information in Livecode compiled apps. They are significantly easier to get into rather than standard APK's. (which is why i'm so eager for LiveCode Embedded).

(Also for the record, binfiling an encrypted SQL database is significantly slower than just filing it. Try it with SQL's over 45 MB's ex. forum db's, game db's)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: mobilepickphoto file type and ftp

Post by jacque » Tue Oct 23, 2012 9:23 pm

Apparently even apps that use SSL are not secure, I just read a warning yesterday that a good number of Android apps are vulnerable to all sorts of data hijacking. Thanks for the info though, it sounds like I'll have to keep my device turned off and in the closet if this gets any worse.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

qberty1337
Posts: 35
Joined: Sun Sep 09, 2012 1:09 pm

Re: mobilepickphoto file type and ftp

Post by qberty1337 » Wed Oct 24, 2012 5:30 am

jacque wrote:Apparently even apps that use SSL are not secure, I just read a warning yesterday that a good number of Android apps are vulnerable to all sorts of data hijacking. Thanks for the info though, it sounds like I'll have to keep my device turned off and in the closet if this gets any worse.
lol well I wouldn't go that far. Just don't store any TOO PERSONAL data on them just YET.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: mobilepickphoto file type and ftp

Post by Mark » Mon Nov 05, 2012 12:14 pm

Hi,

I think that I should add that even though the way Android makes a connection is different, FTP is insecure independently of this, because data are sent unencrypted. If you're using WIFI, the data can be read with a port sniffer as soon as it arrives at your router and between your router and the server there are many places where someone might install a port sniffer. That's why I said FTP is never save.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply

Return to “Android Deployment”