I don't claim to be a ZipArchive expert, but I was able to get the
following to work (based on how .mcz files are created):
| file archive stream member |
archive := ZipArchive new.
file := GsFile open: '/tmp/proc.zip' mode: 'wb' onClient: false.
stream := RWBinaryOrTextStream on: String new.
member := archive
addString:
'<?xml version="1.0"?>
<!DOCTYPE PARTS SYSTEM "parts.dtd">
<?xml-stylesheet type="text/css" href="xmlpartsstyle.css"?>
<PARTS>
<TITLE>Computer Parts</TITLE>
<PART>
<ITEM>Motherboard</ITEM>
<MANUFACTURER>ASUS</MANUFACTURER>
<MODEL>P3B-F</MODEL>
<COST> 123.00</COST>
</PART>
</PARTS>'
as: 'PARTS'.
member desiredCompressionMethod: ZipArchive compressionDeflated.
archive writeTo: stream.
file nextPutAll: stream contents.
file close
Dale
On 4/14/16 12:11 PM, BrunoBB via Glass wrote:
> Hi All,
>
> I'm try to generate a ZIP file with various XML string but with no luck.
> I checked the link but still no ZIP with xml files.
>
http://forum.world.st/How-to-write-a-ziparchive-to-disk-correctly-td3320390.html>
> The Script:
> |file stream archive |
> archive := ZipArchive new.
> file := GsFile open: '/tmp/proc.zip' mode:'wb' onClient: false.
> stream := RWBinaryOrTextStream on: myObject xmlString asByteArray.
> stream binary.
> stream reset.
> file nextPutAll: stream contents.
> archive writeTo: stream.
> file close.
>
> Where [xmlString] is valid XML. I want to generate a ZIP with various XML
> strings.
> But this script only generate an empty ZIP.
>
> Any idea how to create a ZIP with various xml string in it ?
>
> Regards,
> Bruno
>
>
>
> --
> View this message in context:
http://forum.world.st/ZipArchive-usage-tp4890087.html> Sent from the GLASS mailing list archive at Nabble.com.
> _______________________________________________
> Glass mailing list
>
[hidden email]
>
http://lists.gemtalksystems.com/mailman/listinfo/glass_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass