Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using Parse;
- public class ParseBigFile : MonoBehaviour {
- //String linkdownload = "http://files.parsetfss.com/8d7d8fb2-b0bc-4d95-9463-7b2397d0e7ae/tfss-d1e15eac-8c8a-43fd-845b-5f0cf4051b8a-LuongDuLieu.txt";
- String linkdownload = "";
- // Use this for initialization
- void Awake()
- {
- print("Running..");
- }
- void Start() {
- // upload file with parse
- /*
- int soto = 1;
- for (int i = 0; i < soto; i++) {
- //byte[] data = System.Text.Encoding.UTF8.GetBytes("File DataUser Client " + i);
- //ParseFile file = new ParseFile("resume.txt", data);
- String nameFile = "LuongDuLieu.txt";
- String filename = Application.persistentDataPath + "/" + nameFile;
- byte[] bytes = System.IO.File.ReadAllBytes(filename);
- ParseFile file = new ParseFile(nameFile, bytes);
- ParseObject gameScore = new ParseObject("TestBigData");
- gameScore["file"] = file;
- gameScore["id_facebook"] = "idfb " + i;
- gameScore["score"] = i;
- gameScore["level"] = i;
- gameScore.SaveAsync();
- print("i= " + i + " time = " + Time.deltaTime);
- }
- */
- // write file
- /*
- ParseQuery<ParseObject> query = ParseObject.GetQuery("TestBigData");
- query.GetAsync("A04WgJ976D").ContinueWith(t =>
- {
- ParseObject obj = t.Result;
- int level = obj.Get<int>("level");
- string id_facebook = obj.Get<string>("id_facebook");
- ParseFile file = obj.Get<ParseFile>("file");
- print("level = " + level);
- print("id_facebook = " + id_facebook);
- print("file = " + file.Url.AbsoluteUri);
- linkdownload = file.Url.AbsoluteUri;
- });
- String linkUrl = "http://files.parsetfss.com/8d7d8fb2-b0bc-4d95-9463-7b2397d0e7ae/tfss-d1e15eac-8c8a-43fd-845b-5f0cf4051b8a-LuongDuLieu.txt";
- WWW www = new WWW(linkUrl);
- StartCoroutine(Download(www));
- */
- // download file with parse
- StartCoroutine(LoadFile());
- }
- IEnumerator Download(WWW www)
- {
- yield return www;
- print("du lieu = " + www.text);
- byte[] bytes = null;
- bytes = www.bytes;
- String filename = Application.persistentDataPath + "/" + "LuongDuLieu.txt";
- System.IO.File.WriteAllBytes(filename, bytes);
- }
- //void Update() { StartCoroutine(LoadFile()); }
- IEnumerator LoadFile() //single method downloads file
- {
- Debug.Log("LoadFile()");
- ParseQuery<ParseObject> query = ParseObject.GetQuery("TestBigData").WhereEqualTo("objectId", "A04WgJ976D");
- var queryTask = query.FirstAsync();
- while (!queryTask.IsCompleted) yield return null;
- ParseObject obj = queryTask.Result;
- ParseFile pfile = obj.Get<ParseFile>("file");
- Debug.Log(pfile.Url.AbsoluteUri);
- var imageRequest = new WWW(pfile.Url.AbsoluteUri);
- yield return imageRequest;
- Debug.Log("imageRequest " + imageRequest.text);
- }
- }
Add Comment
Please, Sign In to add comment