Cannot use Document stream
Consider the following method:
Thank you for the detailed description of the issue.
Actually I am wondering whether I miss something in reproducing the issue as I tested your code and I successfully saved a .zip file on my local drive. Also to check whether the stream is OK I tried to save it by using a FileStream:
I made a mistake: I should have used stream.Read rather than stream.Write to create the byte array.
With the byte array, I got it to work.
So this didn't work (not sure why):
Please accept my apologies for the late reply.
I am glad that you found a workaround of the issue. However I wonder why the first one is not working on your side. If the workaround satisfies your requirement I'll close the thread, otherwise I'll continue researching the issue although both scenarios work on my side.
the Telerik team
I'm thinking you may not have been able to reproduce my problem because you used a Telerik.Sitefinity.Utilities.Zip.ZipFile rather than Ionic.Zip.ZipFile. It may be interesting to see what makes this fail with Ionic.Zip, as it's possible there is something wrong with the stream that may only cause a failure in certain circumstances (ie: it could also happen in other cases, not just with Ionic.Zip).
So as far as I'm concerned, I've worked around this issue and can now move on to other things, so this doesn't block me anymore. But for the future of Sitefinity, you might want to investigate this some more to fix potential issues. Of course, it's also possible that it's Ionic.Zip that does something wrong (I've never had any problems with this library, though).
I've tested with Ionic library and I can confirm that the following code works:
This how I retrieve the documents:
In this case could you provide us with the source of this function:
Since an Id may be an Id for a draft, live or temp version of a Document, so it is important what Ids do you actually retrieve with this function.
The GetDocumentIds method loads ids from session, so I'll just skip to the relevant part (ie: how documents are loaded in the first place):
Ok so using your code to retrieve the documents you can't get the ZipFile to actually create a Zip file from them?Regards,
I managed to do it by converting the streams to byte arrays, but I couldn't do it directly from the streams, no.
Ok, so is the workaround with converting the Stream to byte array working for you or do you need any additional help for this issue?Regards,
The workaround works, so I'm fine. Thank you.