Ejemplo n.º 1
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;
                    }
                });
            }
        });
    }
Ejemplo n.º 2
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.
                    }
                });
            }
        });
    }
Ejemplo n.º 3
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;
        }
    }
Ejemplo n.º 4
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");
            }
        }
    }
Ejemplo n.º 5
0
 // 이미지를 데이터베이스의 stroage로 부터 파싱하여 화면 상의 sprite로 보여주기 위한 메소드
 private void parsing()
 {
     gs_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) => {
         if (!task.IsFaulted && !task.IsCanceled)
         {
             StartCoroutine(AccessURL(task.Result));
         }
         else
         {
             Debug.Log("URL Download Fault");
         }
     });
 }
Ejemplo n.º 6
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));
            }
        });
    }
Ejemplo n.º 7
0
 public void OnButtonPress()
 {
     penguin_ref.GetDownloadUrlAsync().ContinueWith((Task <Uri> task) =>
     {
         if (!task.IsFaulted && !task.IsCanceled)
         {
             Debug.Log("Download URL: " + task.Result);
             // ... now download the file via WWW or UnityWebRequest.
             WebClient client              = new WebClient();
             client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(DownloadFileCompleted);
             client.DownloadFileAsync(task.Result, "Assets/penguin_bundle1");
             placeObject1.CreateObject("Assets/penguin_bundle1");
         }
     });
 }
Ejemplo n.º 8
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;
        }
    }
Ejemplo n.º 9
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());
            }
        });
    }
Ejemplo n.º 10
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;
                    }
                });
            }
        });
    }
Ejemplo n.º 11
0
    protected void UploadAssetBundleToStorage(string fileName, string filePath, string uploadStoragePath)
    {
        if (!File.Exists(filePath))
        {
            status.SetActive(true);
            status.GetComponent <Text>().text = "Missing Asset Bundles!";
            return;
        }
        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;
                //Debug.Log("download url = " + download_url);
                path_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> getURLtask) => {
                    if (!getURLtask.IsFaulted && !getURLtask.IsCanceled)
                    {
                        AssetsExporter.modelsDict[fileName][AssetsExporter.modelDBBundleURLKey] = getURLtask.Result;
                        Debug.Log(getURLtask.Result);
                    }
                });
            }
        });
    }
Ejemplo n.º 12
0
 public void OnButtonPress()
 {
     foreach (string file_name in System.IO.Directory.GetFiles("Assets/AssetBundles"))
     {
         var file_ref = storage_ref.Child(file_name);
         file_ref.PutFileAsync(file_name).ContinueWith((Task <StorageMetadata> task) =>
         {
             if (task.IsFaulted || task.IsCanceled)
             {
                 Debug.Log(task.Exception.ToString());
             }
             else
             {
                 // Metadata contains file metadata such as size, content-type, and download URL.
                 Firebase.Storage.StorageMetadata metadata = task.Result;
                 var download_result = storage_ref.GetDownloadUrlAsync();
                 Debug.Log("Finished uploading...");
                 Debug.Log("download url = " + download_result.Result);
             }
         });
     }
 }