Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Dave 10 · Mar 14, 2011 at 11:27 PM · savefiledownloadlocalzip

Saving Local Data through WWW

I know this topic has been touched on a couple of times, but I'm still unclear of the exact answer (there's a topic fairly close but doesn't quite address it).

I have a constantly changing remote zip file that I want to download, then take the contents and unzip it using SharpZipLib (which I have working with a local file), and use the contents of the zip file. Is there a way to do this (or a library already available) either using the WWW lib, the WebClient lib, or even through some sort of php mechanism (but then would the unity web player have access to that file)? Or am I stuck with having to stream the content in and working with it that way?

Thanks in advance!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Statement · Mar 14, 2011 at 11:36 PM

If you look at the source code of ExportVisualStudio, there's a section that deals with downloading a zip file off the web using WWW.

Basically I think you should be able to do this:

WWW www = new WWW(url);
yield return www; // Wait for it to download, make the calling function a co-routine.
byte[] bytes = www.bytes; // Here you go!
Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dave 10 · Mar 14, 2011 at 11:48 PM 0
Share

Interesting, and thanks for the quick response. I'm very familiar with downloading via www and obtaining www.bytes, but I'm attempting to work with the resultant .zip file locally as a saved file (through SharpZipLib), so I'm hoping to save the www.bytes to disk. I don't have anything written to deal with the stream of the .zip code unless it's been opened by File.OpenRead first. I have pro, btw.

Thanks!

avatar image Statement · Mar 15, 2011 at 12:15 AM 0
Share

Well if you need to save it to disk and you're not using a web player, then you can just call System.IO.File.WriteAllBytes to write the bytes array to a file in one call.

avatar image Statement · Mar 15, 2011 at 12:17 AM 0
Share

If your SharpZipLib support a stream to do the extracting you can just create a new $$anonymous$$emoryStream.

avatar image Statement · Mar 15, 2011 at 12:21 AM 0
Share

Create a new $$anonymous$$emoryStream and set the contents to the bytes buffer, and follow this sample? http://wiki.sharpdevelop.net/SharpZipLib-Zip-Samples.ashx#Unpack_a_zip_using_ZipInputStream_eg_for_Unseekable_input_streams_5

avatar image Statement · Mar 15, 2011 at 12:22 AM 0
Share

^ Ins$$anonymous$$d of loading with WebClient, just do as in the answer and let data be a $$anonymous$$emoryStream. Create the stream as such var data = new $$anonymous$$emoryStream(bytes);

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Download and save images into local phone storage makes the app hang 1 Answer

Save a file from a URL to documents folder then use it doesn't work 3 Answers

Download and save files to local? 1 Answer

Accessing local system ( File Browser ) 2 Answers

Write Downloaded AssetBundle to Local Storage 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges