Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Saving binary data in ColdFusion

$
0
0

I have a problem with saving a binary representation of a file to a file...

Let me show you my pain:

 

Everything starts with a file, file.pdf

Then the file is send via POST to a website with some additional data:

 

    curl --data "sector=4&name=John&surname=Smith&email=john@smith.com&isocode=PL&theFile=$(cat file.pdf | base64)" http://localhost/awesomeUpload

 

then the data is received and decoded:

 

    var decoded = BinaryDecode(data.theFile, "Base64");

 

then I attempt to save it by:

 

    var theFilePath = ExpandPath("/localserver/temp/theFile.pdf");

    fileWrite(theFilePath , data.theFile);

 

or:     

 

    var file_output_steam = CreateObject("java","java.io.FileOutputStream").init(theFilePath);

        file_output_steam.write(data.theFile);

        file_output_steam.close();

 

My files does not match ;(

 

the original one looks like

 

    %PDF-1.5

    %µµµµ

    1 0 obj

    <</Type/Catalog/Pages 2 0 R/Lang(pl-PL) /StructTreeRoot 13 0 R/MarkInfo<</Marked true>>>>

    endobj

    2 0 obj

    <</Type/Pages/Count 1/Kids[ 3 0 R] >>

    endobj

    3 0 obj

    <</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 10 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 595.32 841.92] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>

 

where as the copy that went through ColdFusion looks like:

 

    %PDF-1.5

    %µµµµ

    1 0 obj

    <</Type/Catalog/Pages 2 0 R/Lang(pl-PL) /StructTreeRoot 13 0 R/MarkInfo<</Marked true>>  ƒB™[™ ŘšƒBڈ   ŘšƒBŹ  Ő \ KÔ YŮ\ËĐŰÝ[ť  KŇÚY ÖČ Č   —H €Đ¦VćFö& ĐŁ2   ö& ĐŁĂÂőG— Rő  vRő  &VçB "   "ő&W6÷W&6W3ĂÂôföçCĂÂôc  R   "ôc"      #ŕ˝AÉ˝ŤM•Ńl˝A  ˝Q•áĐ˝%µ…ť• ˝%µ…ť• ˝%µ…ť•%t€>/MediaBox[ 0 0 595.32 841.92] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0> B™[™ ŘšƒBŤ    ŘšƒBŹ  Ńš[  \‹Ń› ] Q XŰŮ KÓ [™Ý   MŚOʃBśÝ ™X[CBž' cłB°Ś !8 Ě1Ď] CsôŘQ&‰2  PäV˝ëËöĽ˜¨Q Űge•ź

ď ÂŃ,đť@"aK R•˘<1™ [ä¸

(ÄňĄyoâ9S\Śĺ <ę8I± D¬‰#…Ć”ťLé‘ا÷Ín U|WŸ‰˜t`ýuşąĽ\hlu&âĂ ˜7ß

ů"Ĺ\Ŕ>pƒÇ č÷ ÷.°ß’Ř—ˆ—• ‹ĚƒB™[™ Ý ™X[CB™[™ ŘšƒBŤH   ŘšƒBŹ  Ő \ Kћ۝ ÔÝXť \ KŐ \ L И\ŮQ›Űť ĐPŃ QJĐŘ[ XśšKŃ[˜ŰŮ [™ËŇY [ť ] KR Ń \ŘŮ[™ [ť ›Űť Č

ˆ   ‹Ő Ő[šXŰŮ H Ś    ŹŹƒB™[™ ŘšƒBŤˆ   ŘšƒB–Č

Č   —H B™[™ ŘšƒBŤČ   ŘšƒBŹ  И\ŮQ›Űť ĐPŃ QJĐŘ[ XśšKÔÝXť \ KĐŇQ ›Űť  \ L‹Ő \ Kћ۝ ĐŇQ  ŃŇQ X\ ŇY [ť ] KŃ Č L   ĐŇQ Ţ\Ý [R[™›Č     ‹Ń›Űť  \ŘÜš\  ܈ H   ‹ŐČ Śˆ   ƒŕЦVćFö& ĐŁ‚   ö& ĐŁĂÂô÷&FW&–ćr„–FVçF—G’’ ő&Vv—7G'’„ Fö&R’ ő7W  ĆVÖVçB  ăŕЦVćFö& ĐŁ’   ö& ĐŁĂÂőG— RôföçDFW67&— F÷"ôföçDć

 

please help


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>