Esempio n. 1
0
    public void SubmitData()
    {
        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

        reference.Child(emailText).Child(LCGoogleLoginBridge.GSIEmail())
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(_AppRequest));
        reference.Child(messageText.text).Child(_AppRequest.message)
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(_AppRequest));
        reference.Child(locationText.text).Child(_AppRequest.location)
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(_AppRequest));


        StorageReference storage = FirebaseStorage.DefaultInstance.RootReference;

        Firebase.Storage.StorageReference img_ref = storage.Child("UserImages/user.jpg");

        ImageGet.instance.imgTex.GetRawTextureData();

        img_ref.PutBytesAsync(ImageGet.instance.imgTex.GetRawTextureData())
        .ContinueWith((System.Threading.Tasks.Task <StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
            }
            else
            {
                Firebase.Storage.StorageMetadata metadata = task.Result;
                string download_url = metadata.DownloadUrl.ToString();
                Debug.Log("Finished uploading...");
                Debug.Log("download url = " + download_url);
            }
        });
    }
        private StorageReference getByPath(string path)
        {
            FirebaseStorage storage = FirebaseStorage.DefaultInstance;

            Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl(bucketUrl);
            return(storage_ref.Child(path));
        }
    /*
     * Method for publishing a recipe to firebase,
     * Takes in the recipe object that has all the inputted info from the recipe publishing page and a photo of the food
     * then sends the photo to storage and the recipe to our DB
     */
    public void PublishNewRecipe(Recipe recipe, string local_file)
    {
        FirebaseStorage storage = FirebaseStorage.DefaultInstance;
        string          key     = databaseReference.Child("recipes").Push().Key;

        // File located on disk
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://regen-66cf8.appspot.com/Recipes/" + key);
        // Create a reference to the file you want to upload
        storage_ref.PutFileAsync("file://" + local_file)
        .ContinueWith((Task <StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
            }
            else
            {
                Debug.Log("Finished uploading...");
            }
        });
        recipe.ImageReferencePath = $"gs://regen-66cf8.appspot.com/Recipes/" + key;

        string json = JsonUtility.ToJson(recipe);

        databaseReference.Child("recipes").Child(key).SetRawJsonValueAsync(json);

        NotificationManager.Instance.ShowNotification("Publish Successful");
    }
Esempio n. 4
0
    protected void UploadOriginalFileToStorage(string fileName, string filePath, string uploadStoragePath)
    {
        byte[] bytes = File.ReadAllBytes(filePath);
        string path  = uploadStoragePath;

        // Create a reference with an initial file path and name
        Firebase.Storage.StorageReference path_reference =
            storage.GetReference(path);

        // Upload the file to the path "images/rivers.jpg"
        path_reference.PutBytesAsync(bytes)
        .ContinueWith((Task <Firebase.Storage.StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
            }
            else
            {
                // Metadata contains file metadata such as size, content-type, and download URL.
                Firebase.Storage.StorageMetadata metadata = task.Result;
                //string download_url = metadata.DownloadUrl.ToString();
                Debug.Log(fileName + " Finished uploading...");
                progress += 1;
                // Fetch the download URL
                path_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> getURLtask) => {
                    if (!getURLtask.IsFaulted && !getURLtask.IsCanceled)
                    {
                        AssetsExporter.modelsDict[fileName][AssetsExporter.modelDBURLKey] = getURLtask.Result;
                    }
                });
            }
        });
    }
Esempio n. 5
0
    public void BuildTarget()
    {
        if (udt_FrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH)
        {
            udt_targetBuildingBehavior.BuildNewTarget(targetCounter.ToString(), targetBehavior.GetSize().x);

            Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

            Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://ar-demo-1f5c9.appspot.com");

            Firebase.Storage.StorageReference file_ref = storage_ref.Child("images/" + FileControl.FilePath);

            file_ref.PutFileAsync("./Assets/Resources/" + FileControl.FilePath + ".txt").ContinueWith((Task <StorageMetadata> task) =>
            {
                if (task.IsFaulted || task.IsCanceled)
                {
                    Debug.Log("STILL HERE");
                    Debug.Log(task.Exception.ToString());
                    // Uh-oh, an error occurred!
                }
                else
                {
                    // Metadata contains file metadata such as size, content-type, and download URL.
                    Firebase.Storage.StorageMetadata metadata = task.Result;
                    //string download_url = metadata.DownloadUrl.ToString();
                    //Debug.Log("Finished uploading...");
                    //Debug.Log("download url = " + download_url);
                }
            });
        }
    }
Esempio n. 6
0
    public void DownloadLanguageFile(string filePath, string version, Action successAction, Action errorAction, Action <float> updateAction, LoadingViewController loadingView)
    {
        languageFileSuccessCallback = successAction;
        languageFileErrorCallback   = errorAction;
        updateCallback = updateAction;

        languageFileVersion = version;
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Points to the root reference
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://flickpool-84778.appspot.com/");

        Firebase.Storage.StorageReference file_ref = storage_ref.Child(filePath);

        file_ref.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => {
            if (!task.IsFaulted && !task.IsCanceled)
            {
                Debug.Log("Download URL: " + task.Result);
                loadingView.StartCoroutine(DownloadFile(task.Result.ToString(), Utility.GetPathForDownloadedLanguageFile()));
            }
            else
            {
                Debug.Log("error downloading");
                LanguageFileSyncFailed();
            }
        });
    }
    IEnumerator DeleteProcess()
    {
        yield return(new WaitForEndOfFrame());

        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://eduplatform-97d55.appspot.com/");
        // Create a reference to the file you want to upload
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("ccc/" + fileName);                                                                         // 삭제하려는 파일의 레퍼런스...

        // Delete the file
        Task tmpTask = rivers_ref.DeleteAsync().ContinueWith(task => {
            if (task.IsCompleted)
            {
                Debug.Log("File deleted successfully.");
            }
            else
            {
                Debug.Log("error...");
            }
        });

        yield return(new WaitUntil(() => tmpTask.IsCompleted));

        PrintState("delete file complete");
    }
Esempio n. 8
0
    // Update is called once per frame
    public void Poster(Vector2d location, byte[] pic)
    {
        //init datapackage
        DataPackage package = new DataPackage();

        //write some datas
        package.latitude  = location.x;
        package.longitude = location.y;
        package.timeStamp = DateTime.Now.ToString("yyyyMMddhhmmss");

        //upload picture and get urls
        Firebase.Storage.StorageReference pngRef = storage_ref.Child("images").Child(package.timeStamp + ".png");

        // Upload the file to the path "images/rivers.jpg"
        pngRef.PutBytesAsync(pic)
        .ContinueWith((Task <StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
            }
            else
            {
                // Metadata contains file metadata such as size, content-type, and download URL.
                StorageMetadata metadata = task.Result;
                pngRef.GetDownloadUrlAsync().ContinueWith((Task <Uri> task2) => {
                    if (!task2.IsFaulted && !task2.IsCanceled)
                    {
                        Debug.Log("Download URL: " + task2.Result);
                        // ... now download the file via WWW or UnityWebRequest.
                    }
                });
            }
        });
    }
Esempio n. 9
0
    // mp4 movie upload...  테스트 안 해봤음.
    IEnumerator UploadProcessByteBufferMP4Format()
    {
        yield return(new WaitForEndOfFrame());

        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://fir-authtest22.appspot.com");

        string local_file = "";

        if (Application.platform == RuntimePlatform.Android)
        {
            local_file = Application.persistentDataPath + "/" + fileName;
        }
        else
        {
            local_file = "C:/Users/Gana/Downloads/Test_imgs/" + fileName;
        }

        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("stuff/" + fileName);
        WWW www = new WWW("file:///" + local_file);

        while (!www.isDone)
        {
            yield return(null);
        }

        Texture2D tmpTexture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.RGB24, false);

        tmpTexture.SetPixels(www.texture.GetPixels());
        tmpTexture.Apply();
        byte[] bytes = tmpTexture.EncodeToPNG();

        var TmpTask = rivers_ref.PutBytesAsync(bytes, null, new Firebase.Storage.StorageProgress <Firebase.Storage.UploadState>(state =>
        {
            Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            PercentView(state.BytesTransferred, state.TotalByteCount);
        }), System.Threading.CancellationToken.None, null).ContinueWith(task =>
        {
            Debug.Log(string.Format("OnClickUpload::IsCompleted:{0} IsCanceled:{1} IsFaulted:{2}", task.IsCompleted, task.IsCanceled, task.IsFaulted));

            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
            }
            else
            {
                // Metadata contains file metadata such as size, content-type, and download URL.
                Firebase.Storage.StorageMetadata metadata = task.Result;
                Debug.Log("Finished uploading...");
                //foreach (var entry in metadata.DownloadUrls)
                //    Debug.Log("download url = " + entry);
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        PrintState("uploading complete..");
    }
Esempio n. 10
0
    //public static void ChangeCurrentPlayerInBackend(string strUserId, string strPlayerId, PostUserCallback callback)
    //{
    //    auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password).ContinueWith(task =>
    //    {
    //        if (task.IsCanceled)
    //        {
    //            Debug.LogError("SignInAnonymouslyAsync was canceled.");
    //            return;
    //        }
    //        if (task.IsFaulted)
    //        {
    //            Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
    //            return;
    //        }

    //        Firebase.Auth.FirebaseUser newUser = task.Result;
    //        Debug.LogFormat("User signed in successfully: {0} ({1})",
    //            newUser.DisplayName, newUser.UserId);

    //        //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
    //        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

    //        reference.Child("profiles/users").Child(strUserId).Child("current-player-id").SetValueAsync(strPlayerId);
    //    });
    //}

    /* The function call to be allowed only if network is available */
    //public static async Task<DataSnapshot> GetGameData(string userId, string playerId, string gameId, PostUserCallback callback)
    //{
    //    DataSnapshot snapshot = null;
    //    if (userId.Equals(null) || playerId.Equals(null) || gameId.Equals(null))
    //    {
    //        Debug.Log("User ID not found");
    //    }
    //    else
    //    {
    //        try
    //        {
    //            Firebase.Auth.FirebaseUser newUser = await auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password);
    //            Debug.LogFormat("User signed in successfully: {0} ({1})",
    //            newUser.DisplayName, newUser.UserId);

    //            //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
    //            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
    //            snapshot = await reference.Child("profiles/users/" + userId).Child("players").Child(playerId).Child("activity-statistics/games-statistics").Child(gameId).Child("game-data").GetValueAsync();
    //        }
    //        catch(Exception exp)
    //        {
    //            Debug.Log("Failed to GetGameData : " + exp.Message);
    //        }
    //    }
    //    return snapshot;
    //}

    /* The function call to be allowed only if network is available */
    //public static async Task<List<YipliPlayerInfo>> GetAllPlayerdetails(string userId, PostUserCallback callback)
    //{
    //    List<YipliPlayerInfo> players = new List<YipliPlayerInfo>();
    //    DataSnapshot snapshot = null;
    //    if (userId.Equals(null))
    //    {
    //        Debug.Log("User ID not found");
    //    }
    //    else
    //    {
    //        try
    //        {
    //            Firebase.Auth.FirebaseUser newUser = await auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password);
    //            Debug.LogFormat("User signed in successfully: {0} ({1})",
    //            newUser.DisplayName, newUser.UserId);

    //            //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
    //            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
    //            snapshot = await reference.Child("profiles/users/" + userId).Child("players").GetValueAsync();

    //            foreach (var childSnapshot in snapshot.Children)
    //            {
    //                YipliPlayerInfo playerInstance = new YipliPlayerInfo(childSnapshot, childSnapshot.Key);
    //                if(playerInstance.playerId != null)
    //                {
    //                    players.Add(playerInstance);
    //                }
    //                else
    //                {
    //                    Debug.Log("Skipping this instance of player, backend seems corrupted.");
    //                }
    //            }
    //        }
    //        catch(Exception exp)
    //        {
    //            Debug.Log("Failed to GetAllPlayerdetails : " + exp.Message);
    //            return null;
    //        }
    //    }
    //    return players;
    //}

    ///* The function call to be allowed only if network is available */
    //public static async Task<YipliPlayerInfo> GetCurrentPlayerdetails(string userId, PostUserCallback callback)
    //{
    //    Debug.Log("Getting the Default player from backend");

    //    DataSnapshot snapshot = null;
    //    YipliPlayerInfo defaultPlayer = new YipliPlayerInfo();//Cant return null defaultPlayer. Initialze the default player.

    //    if (userId.Equals(null) || userId.Equals(""))
    //    {
    //        Debug.Log("User ID not found");
    //    }
    //    else
    //    {
    //        try
    //        {
    //            Firebase.Auth.FirebaseUser newUser = await auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password);
    //            Debug.LogFormat("User signed in successfully: {0} ({1})",
    //            newUser.DisplayName, newUser.UserId);

    //            //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
    //            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

    //            //First get the current player id from user Id
    //            snapshot = await reference.Child("profiles/users").Child(userId).GetValueAsync();
    //            string playerId = snapshot.Child("current-player-id").Value?.ToString() ?? "";

    //            //Now get the complete player details from Player Id
    //            DataSnapshot defaultPlayerSnapshot = await reference.Child("profiles/users/" + userId + "/players/" + playerId).GetValueAsync();

    //            defaultPlayer = new YipliPlayerInfo(defaultPlayerSnapshot, defaultPlayerSnapshot.Key);

    //            if (defaultPlayer.playerId != null)
    //            {
    //                //Do Nothing
    //                Debug.Log("Found Default player : " + defaultPlayer.playerId);
    //            }
    //            else
    //            {
    //                //Case to handle if the default player object doesnt exist in backend/or is corrupted
    //                Debug.Log("Default Player Not found. Returning null.");
    //                return null;
    //            }
    //        }
    //        catch(Exception exp)
    //        {
    //            //If couldnt get defualt player details from the backend, return null.
    //            Debug.Log("Failed to GetAllPlayerdetails: " + exp.Message);
    //            return null;
    //        }
    //    }

    //    return defaultPlayer;
    //}


    // Mat related queries

    /* The function call to be allowed only if network is available */
    //public static async Task<YipliMatInfo> GetCurrentMatDetails(string userId, PostUserCallback callback)
    //{
    //    Debug.Log("Getting the Default mat from backend");
    //    DataSnapshot snapshot = null;
    //    YipliMatInfo defaultMat = new YipliMatInfo();

    //    if (userId.Equals(null) || userId.Equals(""))
    //    {
    //        Debug.Log("User ID not found");
    //    }
    //    else
    //    {
    //        try
    //        {
    //            Firebase.Auth.FirebaseUser newUser = await auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password);
    //            Debug.LogFormat("User signed in successfully: {0} ({1})",
    //            newUser.DisplayName, newUser.UserId);

    //            //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
    //            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

    //            //First get the current mat id from user Id
    //            snapshot = await reference.Child("profiles/users").Child(userId).GetValueAsync();

    //            string matId = snapshot.Child("current-mat-id").Value?.ToString() ?? "";
    //            //Now get the complete player details from Player Id
    //            DataSnapshot defaultMatSnapshot = await reference.Child("profiles/users/" + userId + "/mats/" + matId).GetValueAsync();
    //            defaultMat = new YipliMatInfo(defaultMatSnapshot, defaultMatSnapshot.Key);

    //            if (defaultMat.matId != null)
    //            {
    //                //Do Nothing
    //                Debug.Log("Found Default mat : " + defaultMat.matId);
    //            }
    //            else
    //            {
    //                //Case to handle if the default mat object doesnt exist in backend/or is corrupted
    //                return null;
    //            }
    //        }
    //        catch(Exception exp)
    //        {
    //            Debug.Log("Failed to GetAllMatdetails : " + exp.Message);
    //            return null;
    //        }
    //    }
    //    return defaultMat;
    //}

    /* The function call to be allowed only if network is available */
    //public static async Task<List<YipliMatInfo>> GetAllMatDetails(string userId, PostUserCallback callback)
    //{
    //    List<YipliMatInfo> mats = new List<YipliMatInfo>();
    //    DataSnapshot snapshot = null;
    //    if (userId.Equals(null) || userId.Equals(""))
    //    {
    //        Debug.Log("User ID not found");
    //    }
    //    else
    //    {
    //        try
    //        {
    //            Firebase.Auth.FirebaseUser newUser = await auth.SignInWithEmailAndPasswordAsync(YipliHelper.userName, YipliHelper.password);
    //            Debug.LogFormat("User signed in successfully: {0} ({1})",
    //            newUser.DisplayName, newUser.UserId);

    //            //FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://yipli-project.firebaseio.com/");
    //            DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
    //            snapshot = await reference.Child("profiles/users/" + userId + "/mats").GetValueAsync();

    //            foreach (var childSnapshot in snapshot.Children)
    //            {
    //                YipliMatInfo matInstance = new YipliMatInfo(childSnapshot, childSnapshot.Key);
    //                if(matInstance.matId != null)
    //                {
    //                    mats.Add(matInstance);
    //                }
    //                else
    //                {
    //                    Debug.Log("Skipping this instance of mat, backend seems corrupted.");
    //                }
    //            }
    //        }
    //        catch(Exception exp)
    //        {
    //            Debug.Log("Failed to GetAllPlayerdetails : " + exp.Message);
    //        }
    //    }
    //    return mats;
    //}


    /*
     * profilePicUrl : Player profile pic property stored already
     * onDeviceProfilePicPath : Path to store the image locally
     */
    public static async Task <Sprite> GetImageAsync(string profilePicUrl, string onDeviceProfilePicPath)
    {
        Debug.Log("Local path : " + onDeviceProfilePicPath);

        // Get a reference to the storage service, using the default Firebase App
        Firebase.Storage.StorageReference storage_ref = yipliStorage.GetReferenceFromUrl(profilePicRootUrl + profilePicUrl);

        Debug.Log("File download started.");

        try
        {
            // Start downloading a file and store it at local_url path
            await storage_ref.GetFileAsync(onDeviceProfilePicPath);

            byte[]    bytes   = System.IO.File.ReadAllBytes(onDeviceProfilePicPath);
            Texture2D texture = new Texture2D(1, 1);
            texture.LoadImage(bytes);
            Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));

            Debug.Log("Profile image downloaded.");
            return(sprite);
        }
        catch (Exception exp)
        {
            Debug.Log("Failed to download Profile image : " + exp.Message);
            return(null);
        }
    }
    IEnumerator AssetBudleDownloadLocal()                                                                               // 로컬 방식 다운로드..
    {
        bLoading = true;
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        //Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://fir-authtest22.appspot.com");
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://eduplatform-97d55.appspot.com/");
        // Create a reference to the file you want to upload
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("AssetBundleTest1/" + assetBundleName);                            // 업로드 확인해야 함...

        string local_file = "";

        if (Application.platform == RuntimePlatform.Android)
        {
            if (!Directory.Exists(Application.persistentDataPath + "/" + "AssetBundle"))                                                    //폴더가 있는지 체크하고 없으면 만든다.
            {
                Directory.CreateDirectory(Application.persistentDataPath + "/" + "AssetBundle");
            }
            if (File.Exists(Application.persistentDataPath + "/" + "AssetBundle" + "/" + assetBundleName))
            {
                StartCoroutine(AssetBundleLoadFromLocal());                                                                                                 // 에셋번들 로드...
                yield break;
            }
            local_file = Application.persistentDataPath + "/" + "AssetBundle" + "/" + assetBundleName;
        }
        else
        {
            if (File.Exists("C:/Users/Gana/Downloads/AssetBundle/AssetBundle_PC" + "/" + assetBundleName))
            {
                StartCoroutine(AssetBundleLoadFromLocal());
                yield break;
            }
            local_file = "C:/Users/Gana/Downloads/AssetBundle/AssetBundle_PC" + "/" + assetBundleName;
        }

        Task TmpTask = rivers_ref.GetFileAsync(local_file, new Firebase.Storage.StorageProgress <Firebase.Storage.DownloadState>(state =>
        {
            // 다운로드 진행률....
            Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            PercentView(state.BytesTransferred, state.TotalByteCount);
        })).ContinueWith(task => {
            Debug.Log(string.Format("OnClickDownload::IsCompleted:{0} IsCanceled:{1} IsFaulted:{2}", task.IsCompleted, task.IsCanceled, task.IsFaulted));
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                bLoading = false;
            }
            else
            {
                Debug.Log("Finished downloading...");
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        PrintState("Downloading Complete");
        StartCoroutine(AssetBundleLoadFromLocal());
    }
Esempio n. 12
0
    public void takeAPic(Button button)
    {
        //disable button function
        button.interactable = false;
        try
        {
            webcamTexture.GetPixels32(colors);
            texture.SetPixels32(colors);
            texture.Apply();
            png = texture.EncodeToPNG();

            //init datapackage
            DataPackage package = new DataPackage();

            //write some datas
            package.latitude  = users.LocationProvider.CurrentLocation.LatitudeLongitude.x;
            package.longitude = users.LocationProvider.CurrentLocation.LatitudeLongitude.y;
            package.timeStamp = DateTime.Now.ToString("yyyyMMddhhmmss");

            //upload picture and get urls
            Firebase.Storage.StorageReference pngRef = storage_ref.Child("images").Child(package.timeStamp + ".png");

            // Upload the file to the path "images/rivers.jpg"
            pngRef.PutBytesAsync(png).ContinueWith((Task <StorageMetadata> task) =>
            {
                if (task.IsFaulted || task.IsCanceled)
                {
                    Debug.Log(task.Exception.ToString());
                    // Uh-oh, an error occurred!
                }
                else
                {
                    // Metadata contains file metadata such as size, content-type, and download URL.
                    StorageMetadata metadata = task.Result;
                    pngRef.GetDownloadUrlAsync().ContinueWith((Task <Uri> task2) =>
                    {
                        if (!task2.IsFaulted && !task2.IsCanceled)
                        {
                            Debug.Log("Download URL: " + task2.Result);
                            package.picURL = task2.Result.ToString();
                            string json    = JsonUtility.ToJson(package);
                            //make location of containing data
                            string key = reference.Child("Cat").Push().Key;
                            reference.Child("Cat").Child(key).SetRawJsonValueAsync(json);
                        }
                    });
                }
            });
        }
        catch (Exception e)
        {
            throw;
        }
        finally {
            //eable button function
            button.interactable = true;
        }
    }
Esempio n. 13
0
    void OnDestroy()
    {
        // Write and save game data to .json file
        string saveText = JsonUtility.ToJson(listw);

        Debug.Log("readAler: " + saveText);

        string datetime = DateTime.Now.ToString("yyyyMMddHHmmss");


        if (!Directory.Exists(out_folder))
        {
            Directory.CreateDirectory(out_folder);
        }

        if (!Directory.Exists(out_folder + gameObject.name + "/" + "pickup/"))
        {
            Directory.CreateDirectory(out_folder + gameObject.name + "/" + "pickup/");
        }

        string filename       = "pickup_" + datetime + ".json";
        string local_filepath = out_folder + gameObject.name + "/" + "pickup/" + filename;

        File.WriteAllText(local_filepath, saveText); // TODO @Matthew: This takes 2 arguments, the filepath and the json saveText var

        // Get a reference to Firebase cloud storage service
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

        // Create storage reference from our storage service bucket
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://unityoptics-eafc0.appspot.com");

        //  Create a reference to newly created .json file
        Firebase.Storage.StorageReference game_data_ref = storage_ref.Child(filename);

        // Create reference to 'gameData/filename'
        Firebase.Storage.StorageReference game_data_json_ref =
            storage_ref.Child("gameData/" + gameObject.name + "/" + "pickup/" + filename);

        // Upload Files to Cloud FireStore
        game_data_json_ref.PutFileAsync(local_filepath)
        .ContinueWith((System.Threading.Tasks.Task <StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Error Occured
            }
            else
            {
                //Metadata contains file metadata such as size, content-type, and download URL.
                Firebase.Storage.StorageMetadata metadata = task.Result;
                // string download_url = metadata.DownloadUrl.ToString();
                Debug.Log("Finished uploading...");
                // Debug.Log("download url = " + download_url);
            }
        });
    }
    IEnumerator DownloadCacheImgByBuffer()                                                                      // 이미지를 로컬에 저장하지 않고, cache 메모리에 저장 후 화면에 표시..
    {
        bool bError = false;

        byte[] fileContents2 = null;

        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        //Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://fir-authtest22.appspot.com");
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://eduplatform-97d55.appspot.com/");
        // Create a reference to the file you want to upload
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("ccc/" + fileName);

        // 최대 사이즈 지정할 수 있음..
        const long maxAllowedSize = 5 * 1024 * 1024;                                    // 최대사이즈 일단 5mb
        var        TmpTask        = rivers_ref.GetBytesAsync(maxAllowedSize, new Firebase.Storage.StorageProgress <Firebase.Storage.DownloadState>(state =>
        {
            // 다운로드 진행율 표시...
            Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            PercentView(state.BytesTransferred, state.TotalByteCount);
        })).ContinueWith((System.Threading.Tasks.Task <byte[]> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
                bError = true;
            }
            else if (task.IsCompleted)
            {
                Debug.Log("Finished downloading!");
                fileContents2 = task.Result;
                bError        = false;
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        if (false == bError)
        {
            Texture2D tmpTexture = new Texture2D(16, 16, TextureFormat.RGB24, false);
            bool      isLoaded   = tmpTexture.LoadImage(fileContents2);
            while (!isLoaded)
            {
                yield return(null);
            }

            tmpTexture.name = "tmpTexutre";
            rawImage.gameObject.SetActive(true);
            rawImage.texture = tmpTexture;
            PrintState("image view");
        }
        else if (true == bError)
        {
            PrintState("Error...");
        }
    }
Esempio n. 15
0
    public void clickUpload()
    {
        uploadPanel.SetActive(false);
        uploadStatus.SetActive(true);
        closeStatus.SetActive(false);

        status.text = "Sedang mempersiapkan file.";
        StartCoroutine(AnimateText());
        try {
            // Get a reference to the storage service, using the default Firebase App
            Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

            // Create a storage reference from our storage service
            Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://buddhist-festival-ar-2018.appspot.com");

            // Create a child reference
            // images_ref now points to "images"
            Firebase.Storage.StorageReference images_ref = storage_ref.Child("Lomba Foto/" + PlayerPrefs.GetString("Nama", "") + "_" + PlayerPrefs.GetString("Telepon", "") + "/" + SaveLoad.imageName[activeIndex]);

            // Data in memory
            byte[] custom_bytes = SaveLoad.imageTexture[activeIndex].EncodeToPNG();

            status.text = "Sedang Meng-upload Foto";

            // Create file metadata including the content type
            //Firebase.Storage.MetadataChange new_metadata = new Firebase.Storage.MetadataChange();
            //new_metadata.ContentType = "image/png";

            // Upload the file to the path "images/rivers.jpg"
            images_ref.PutBytesAsync(custom_bytes)
            .ContinueWith((task) => {
                if (task.IsFaulted || task.IsCanceled)
                {
                    //status.text = "Gagal mengupload foto.\n Pesan error:\n"+ task.Exception.ToString();
                    status.text = "Gagal mengupload foto.";
                    isanimate   = false;
                    closeStatus.SetActive(true);
                    // Uh-oh, an error occurred!
                }
                else
                {
                    // Metadata contains file metadata such as size, content-type, and download URL.
                    //Firebase.Storage.StorageMetadata metadata = task.Result;
                    status.text = "Upload selesai. Terima kasih sudah berpartisipasi dalam lomba foto.";
                    isanimate   = false;
                    closeStatus.SetActive(true);
                }
            });
        } catch (System.Exception ex) {
            //status.text = "Gagal mengupload foto.\n Pesan error:\n"+ ex.ToString();
            status.text = "Gagal mengupload foto.";
            isanimate   = false;
            closeStatus.SetActive(true);
        }
    }
Esempio n. 16
0
    // Start is called before the first frame update
    void Start()
    {
#if UNITY_ANDROID
        assetReferance = storage.GetReferenceFromUrl(storageBaseURL + "/AssetBundles/Android/StandardPackages/Animals");
#endif
#if UNITY_IOS
        assetReferance = storage.GetReferenceFromUrl(storageBaseURL + "/AssetBundles/iOS/StandardPackages/Animals");
#endif

        StartCoroutine(UpdateUI());
    }
Esempio n. 17
0
    public void NextOnClick()
    {
        byte[] image = texture.EncodeToPNG();

        website  = websiteField.GetComponent <Text>().text;
        facebook = facebookField.GetComponent <Text>().text;
        linkedIn = linkedInField.GetComponent <Text>().text;
        phone    = phoneField.GetComponent <Text>().text;

        string card_id = PlayerPrefs.GetString("card_id");

        if (!string.IsNullOrEmpty(card_id))
        {
            if (!string.IsNullOrEmpty(website) && !string.IsNullOrEmpty(facebook) && !string.IsNullOrEmpty(linkedIn) && !string.IsNullOrEmpty(phone))
            {
                storage          = Firebase.Storage.FirebaseStorage.DefaultInstance;
                storageReference = storage.GetReferenceFromUrl("gs://card-677f1.appspot.com/augment_images/");
                Firebase.Storage.StorageReference targetReference = storageReference.Child(authUser.UserId + card_id);
                databaseReference = FirebaseDatabase.DefaultInstance.RootReference;

                targetReference.PutBytesAsync(image)
                .ContinueWith((Task <StorageMetadata> task) => {
                    if (task.IsFaulted || task.IsCanceled)
                    {
                        Debug.Log(task.Exception.ToString());
                        // Uh-oh, an error occurred!
                    }
                    else
                    {
                        targetReference.GetDownloadUrlAsync().ContinueWith((Task <Uri> uriTask) =>
                        {
                            string download_url = uriTask.Result.ToString();
                            Debug.Log("Finished uploading...");
                            Debug.Log("download url = " + download_url);
                            DatabaseReference childReference = databaseReference.Child("cards").Child(card_id);
                            childReference.Child("website").SetValueAsync(website);
                            childReference.Child("facebook").SetValueAsync(facebook);
                            childReference.Child("linkedIn").SetValueAsync(linkedIn);
                            childReference.Child("phone").SetValueAsync(phone);
                            childReference.Child("photo").SetValueAsync(download_url);
                        });
                    }
                });

                SceneManager.LoadScene("HomeScene");
            }

            else
            {
                print("ERROR IN FIELDS");
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        captureButton = GameObject.Find("Capture");
        errorText     = GameObject.Find("Error").GetComponent <Text>();

        // Get a reference to the storage service, using the default Firebase App
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref =
            storage.GetReferenceFromUrl("gs://buddhist-festival-ar-2018.appspot.com");
    }
    // 파이어 베이스에서 내려받음....
    IEnumerator AssetBudleDownLoad(string _strUrl, string _strDir, string _strBundleName)
    {
        string assetBundleName = _strBundleName;

        bLoading = true;
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://sohn123-f1d8d.appspot.com/");
        // Create a reference to the file you want to upload
        //Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("AssetBundle/" + assetBundleName);                            // 업로드 확인해야 함...
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child(_strUrl);                                                                              // 업로드 확인해야 함...


        string local_file = "";

        if (Application.platform == RuntimePlatform.Android)
        {
            // 아래 수정 해야 함....
            if (!Directory.Exists(Application.persistentDataPath + "/AssetBundle/ " + _strDir))                                                    //폴더가 있는지 체크하고 없으면 만든다.
            {
                Directory.CreateDirectory(Application.persistentDataPath + "/AssetBundle/ " + _strDir);
            }
            local_file = Application.persistentDataPath + "/AssetBundle/" + _strDir + "/" + _strBundleName;
        }
        else
        {
            local_file = "C:/Users/Gana/Downloads/AssetBundle/" + _strDir + "/" + _strBundleName;                                                // PC ....
        }

        Task TmpTask = rivers_ref.GetFileAsync(local_file, new Firebase.Storage.StorageProgress <Firebase.Storage.DownloadState>(state =>
        {
            // 다운로드 진행률....
            //Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            PercentView(state.BytesTransferred, state.TotalByteCount);
        })).ContinueWith(task => {
            //Debug.Log(string.Format("OnClickDownload::IsCompleted:{0} IsCanceled:{1} IsFaulted:{2}", task.IsCompleted, task.IsCanceled, task.IsFaulted));
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                bLoading = false;
            }
            else
            {
                //Debug.Log("Finished downloading...");
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        //PrintState("Downloading Complete");
        //StartCoroutine(AssetBundleLoadFromLocal());
        Debug.Log("Finished");
    }
    // Start is called before the first frame update
    void Start()
    {
        // Get a reference to the storage service, using the default Firebase App
        FirebaseStorage storage = FirebaseStorage.DefaultInstance;

        // Create a storage reference from our storage service
        storage_ref = storage.GetReferenceFromUrl("URL");

        uploadFile();
        downloadFile();
        //deleteFile();
    }
Esempio n. 21
0
    // Start is called before the first frame update
    void Start()
    {
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

        // Get the root reference location of the database.
        storage_ref = storage.GetReferenceFromUrl("gs://doodle-maze-2020.appspot.com");

        // Ensures members of this class can be accessed by other scripts in different scenes
        DontDestroyOnLoad(this.gameObject);

        // Disable screen dimming
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
    }
Esempio n. 22
0
    void obtenerArchivo(string nombre, string extencion, string codigo)
    {
        Debug.Log("ARCHIVO BUSCADO: " + nombre + "&&" + codigo + "." + extencion);
        Firebase.Storage.FirebaseStorage  storage   = Firebase.Storage.FirebaseStorage.DefaultInstance;
        Firebase.Storage.StorageReference reference =
            storage.GetReference(nombre + "&&" + codigo + "." + extencion);

        reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> linkDescarga) =>
        {
            if (!linkDescarga.IsFaulted && !linkDescarga.IsCanceled)
            {
                StartCoroutine(descargar(linkDescarga.Result.ToString(), nombre, extencion, codigo));
            }
        });
    }
Esempio n. 23
0
    IEnumerator DownloadTexture()
    {
        Firebase.Storage.StorageReference texture_ref = GetStorageReference().Child(textureFIleName);
        // Fetch the download URL
        var task = texture_ref.GetDownloadUrlAsync();

        yield return(new WaitUntil(() => task.IsCompleted));

        using (WWW www = CachedDownloader.GetCachedWWW(task.Result.ToString()))
        {
            yield return(www);

            Renderer renderer = cube.GetComponent <Renderer>();
            renderer.material.mainTexture = www.texture;
        }
    }
Esempio n. 24
0
    void Test()
    {
        Debug.Log("downloading image");
        Firebase.Storage.FirebaseStorage  storage     = Firebase.Storage.FirebaseStorage.DefaultInstance;
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://stargaze-embedded.appspot.com/image.jpg");

        // Create local filesystem URL
        string local_url = "file:///local/images/image.jpg";

        // Download to the local filesystem
        storage_ref.GetFileAsync(local_url).ContinueWith(task => {
            if (!task.IsFaulted && !task.IsCanceled)
            {
                Debug.Log("File downloaded.");
            }
        });
    }
    IEnumerator DownloadByBufferTxt()                                                                                  // 텍스트를 로컬에 저장하지 않고, cache 메모리에 저장 후 화면에 표시.. 한글은 UTF-8 만 가능.
    {
        bool bError = false;

        byte[] fileContents = null;

        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://eduplatform-97d55.appspot.com/");
        // Create a reference to the file you want to upload
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("ccc/text_1.txt");

        // 최대 사이즈....
        const long maxAllowedSize = 2 * 1024 * 1024;    // 2mb
        var        TmpTask        = rivers_ref.GetBytesAsync(maxAllowedSize, new Firebase.Storage.StorageProgress <Firebase.Storage.DownloadState>(state =>
        {
            // 다운로드 진행율 표시...
            Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            PercentView(state.BytesTransferred, state.TotalByteCount);
        })).ContinueWith((System.Threading.Tasks.Task <byte[]> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
                bError = true;
            }
            else if (task.IsCompleted)
            {
                Debug.Log("Finished downloading!");
                fileContents = task.Result;
                bError       = false;
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        if (false == bError)
        {
            string testText = System.Text.Encoding.UTF8.GetString(fileContents);                                       // UTF8로 인코딩하여서 변환...
            PrintState("lyrics: " + testText);
        }
        else if (true == bError)
        {
            PrintState("Error...");
        }
    }
Esempio n. 26
0
    //	gs://appointmentproject-a7233.appspot.com/CompanyImages/z0iJvJUBK2aK2BP2OAuACDrNMSn1/companyImage.jpg
    public void LoadImage(string companyID, Delegates.OnSpriteSuccess success)
    {
        var filepath = string.Format("{0}/{1}/{2}/{3}{4}", bucketReference, ChildsReferences.CompanyImages.ToString(), companyID, ChildsReferences.companyImage.ToString(), format);

        Firebase.Storage.StorageReference gs_reference = storage.GetReferenceFromUrl(filepath);
        gs_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => {
            if (!task.IsFaulted && !task.IsCanceled)
            {
                Debug.Log("Download URL: " + task.Result);
                StartCoroutine(LoadImageInternet(task.Result.ToString(), success));
            }
            else
            {
                Debug.Log(task.Exception.ToString());
            }
        });
    }
    IEnumerator LocalDownloadXmlQuiz(string _fileName)
    {
        // test....
        fileName = _fileName;
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://eduplatform-97d55.appspot.com/");                                         // 파이어베이스 계정에 할당된 주소...
        // Create a reference to the file you want to upload
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("XmlFile_Chuncheon/" + fileName);                                                          // 하위 폴더...

        string local_file = "";

        // 경로 지정....
        if (Application.platform == RuntimePlatform.Android)
        {
            local_file = Application.persistentDataPath + "/" + fileName;                                           // android 의 접근 가능한 주소,, 폴더 추가 가능..
        }
        else
        {
            local_file = Application.streamingAssetsPath + "/" + fileName;
        }

        Task TmpTask = rivers_ref.GetFileAsync(local_file, new Firebase.Storage.StorageProgress <Firebase.Storage.DownloadState>(state =>
        {
            // 다운로드 진행율 표시...
            Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            //PercentView(state.BytesTransferred, state.TotalByteCount);
        })).ContinueWith(task => {
            Debug.Log(string.Format("OnClickDownload::IsCompleted:{0} IsCanceled:{1} IsFaulted:{2}", task.IsCompleted, task.IsCanceled, task.IsFaulted));
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
                Debug.Log("Oops,, Error..");
            }
            else
            {
                Debug.Log("Finished downloading...");
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        bXmlFileQuiz = true;
    }
Esempio n. 28
0
    protected void GrabPixelsOnPostRender(string fileName)
    {
        //Create a new texture with the width and height of the screen
        Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);

        //Read the pixels in the Rect starting at 0,0 and ending at the screen's width and height
        texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false);
        texture.Apply();
        byte[] bytes = texture.EncodeToPNG();
        string path  = AssetsExporter.imagesStorageURL + fileName + ".png";

        // Create a reference with an initial file path and name
        Firebase.Storage.StorageReference path_reference =
            storage.GetReference(path);

        // Upload the file to the path "images/rivers.jpg"
        path_reference.PutBytesAsync(bytes)
        .ContinueWith((Task <Firebase.Storage.StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                Debug.Log("task failed: " + path + " " + fileName);
                // Uh-oh, an error occurred!
            }
            if (task.IsCanceled)
            {
                Debug.Log("task was canceled");
            }
            else
            {
                // Metadata contains file metadata such as size, content-type, and download URL.
                Firebase.Storage.StorageMetadata metadata = task.Result;
                //string download_url = metadata.DownloadUrl.ToString();
                Debug.Log(fileName + " Finished uploading...");
                progress += 1;
                // Fetch the download URL
                path_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> getURLtask) => {
                    if (!getURLtask.IsFaulted && !getURLtask.IsCanceled)
                    {
                        AssetsExporter.modelsDict[fileName][AssetsExporter.modelDBImageKey][AssetsExporter.modelDBImageURLKey] = getURLtask.Result;
                    }
                });
            }
        });
    }
Esempio n. 29
0
    void InitializeFirebase()
    {
        FirebaseApp app = FirebaseApp.DefaultInstance;

        app.SetEditorDatabaseUrl("https://vr-one-4e3bb.firebaseio.com/");

        // Get a reference to the storage service, using the default Firebase App
        storage = Firebase.Storage.FirebaseStorage.DefaultInstance;

        // Create a storage reference from our storage service
        storage_ref = storage.GetReferenceFromUrl("gs://vr-one-4e3bb.appspot.com/");
        //Firebase.Storage.StorageReference images_ref = storage_ref.Child ("map");
        screenshot_ref = storage_ref.Child("map/Screenshot.png");



        //items = new ArrayList();
    }
Esempio n. 30
0
    // 로컬 다운로드...
    IEnumerator LocalDownloadStart()
    {
        // 로컬 방식....
        Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance;
        // Create a storage reference from our storage service
        Firebase.Storage.StorageReference storage_ref = storage.GetReferenceFromUrl("gs://fir-authtest22.appspot.com");
        // Create a reference to the file you want to upload
        Firebase.Storage.StorageReference rivers_ref = storage_ref.Child("AssetBundleTest1/" + fileName);

        string local_file = "";

        if (Application.platform == RuntimePlatform.Android)
        {
            local_file = Application.persistentDataPath + "/" + fileName;                           // android 의 접근 가능한 주소,, 폴더 추가 가능..
        }
        else
        {
            local_file = "C:/Users/Gana/Downloads/AsssetBundle/" + fileName;
        }

        //var TmpTask = rivers_ref.GetFileAsync(local_file).ContinueWith(task => {
        var TmpTask = rivers_ref.GetFileAsync(local_file, new Firebase.Storage.StorageProgress <Firebase.Storage.DownloadState>(state =>
        {
            Debug.Log(string.Format("Progress: {0} of {1} bytes transferred.", state.BytesTransferred, state.TotalByteCount));
            PercentView(state.BytesTransferred, state.TotalByteCount);
        })).ContinueWith(task => {
            Debug.Log(string.Format("OnClickDownload::IsCompleted:{0} IsCanceled:{1} IsFaulted:{2}", task.IsCompleted, task.IsCanceled, task.IsFaulted));
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
                // Uh-oh, an error occurred!
                //authUI.ShowNotice("Error....");
                Debug.Log("Oops,, Error..");
            }
            else
            {
                Debug.Log("Finished downloading...");
            }
        });

        yield return(new WaitUntil(() => TmpTask.IsCompleted));

        PrintState("Finished downloading...");
    }