This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Binary data via XML  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was tying out to see if it is possible to send binary information(like an .jpeg file or .ppt file) embedded in an xml.
I was trying to have the file name and some more details in the xml and one of the tags in the xml would be the binary file itself. Is it possible to do this? The xml file so created will be moved from one location to another using SFTP. In the receiving location, I will have to store the file as it is - after extracting it(if required).

Any better suggestions on this are welcome.

Thanks,
Anoop
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Encode it with base64!
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry, your solution is 6 times less efficient than base64 in terms of space usage, you have 1 character/bit vs. 1 char/6bits, as with base64!
 
Anu Host
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion.
I was trying out some text which was encoded and decoded using base64 and it seems to work fine. Wanted to know if this is ok to be used for .jpeg files and if there are any chances for the image to be corrupted when decoding. I came to know that base64 uses only a-z, A-Z, 0-9, + and / but wanted to know if it is safe to use this in an xml.
 
Sheriff
Posts: 23648
49
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anu Host wrote:I was trying out some text which was encoded and decoded using base64 and it seems to work fine. Wanted to know if this is ok to be used for .jpeg files and if there are any chances for the image to be corrupted when decoding.


Base64 would be pretty useless if it didn't decode back to the original, wouldn't it?

I came to know that base64 uses only a-z, A-Z, 0-9, + and / but wanted to know if it is safe to use this in an xml.


XML would be pretty useless if it couldn't contain all of those characters, wouldn't it?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!