Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

Base64 Encode : Create and write image to server for download later.

I need to convert base64 file encoded from a tif into a TIF file. How would I convert it and write it to a tif file for a user to download?

Thank you!

If you want to see the 64 bit image let me know I will pull it up for you.
0
nfmesa
Asked:
nfmesa
  • 2
  • 2
  • 2
2 Solutions
 
wesbirdCommented:
This works for me on decode: http://www.motobit.com/tips/detpg_Base64/

You may also want to use this technique: http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21368039.html

to server the bytes using the ADODB.Stream object.  You should also modify the content disposition type.

Wes
0
 
nfmesaAuthor Commented:
Wes, after you decode it how do you get it to create the image though?
0
 
wesbirdCommented:
Decode it on the fly and push the bytes directly out as a separate ASP page using the ADODB.Stream object.  You can do this without saving the file if you use an ActiveX DLL.  If it's just ASP you may have to save the file first and load it into the ADODB.Stream object because byte data type is not easily available from ASP/VBscript.

e.g.

Response.ContentType = "image/TIFF"
Response.AddHeader "content-disposition", "attachment; filename=" & strFilename
Response.BinaryWrite bObject

or take a look at this: http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21638573.html

The main thing is to call Response.BinaryWrite.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
nfmesaAuthor Commented:
I used the function from above and I keep getting a bad base64 string. The string is coming right from a USPS xml feed from there servers for a label... Please advice...
0
 
sybeCommented:
Function Base64Encode(ByVal vCode)
    Dim oXML, oNode

    On Error Resume Next

    Set oXML = Server.CreateObject("Msxml2.DOMDocument.3.0")
    Set oNode = oXML.CreateElement("base64")
    oNode.dataType = "bin.base64"
    oNode.nodeTypedValue = vCode
    Base64Encode = oNode.text
    Set oNode = Nothing
    Set oXML = Nothing
End Function


Function Base64Decode(ByVal vCode)
    Dim oXML, oNode

    On Error Resume Next

    Set oXML = Server.CreateObject("Msxml2.DOMDocument.3.0")
    Set oNode = oXML.CreateElement("base64")
    oNode.dataType = "bin.base64"
    oNode.text = vCode
    Base64Decode = oNode.nodeTypedValue
    Set oNode = Nothing
    Set oXML = Nothing
End Function
0
 
sybeCommented:
You might want to experiment with another variant of "Msxml2.DOMDocument.3.0"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now