Exemple #1
0
 public void renameFile()
 {
     BacktoryFile.RenameInBackground(serverFilePathInput.text, newFileNameInput.text, (response) => {
         ResultText.text = response.Successful ? "Rename file succeeded.\n" +
                           JsonConvert.SerializeObject(response.Body, Formatting.Indented, JsonnetSetting()) : "failed; " + response.Message;
     });
 }
Exemple #2
0
    public void UploadData()
    {
        LoadingPanel.SetActive(true);
        ///upload St.alpha
        if (File.Exists(Application.persistentDataPath + "/Data/ST.alpha"))
        {
            BacktoryFile backtoryFile = new BacktoryFile(Application.persistentDataPath + "/Data/ST.alpha");
            backtoryFile.UploadInBackground("/" + PlayerPrefs.GetString("Username") + "/", true, (response) =>
            {
                if (response.Successful)
                {
                    ///Upload CH.alpha

                    if (File.Exists(Application.persistentDataPath + "/Data/CH.alpha"))
                    {
                        backtoryFile = new BacktoryFile(Application.persistentDataPath + "/Data/CH.alpha");
                        backtoryFile.UploadInBackground("/" + PlayerPrefs.GetString("Username") + "/", true, (res) =>
                        {
                            if (res.Successful)
                            {
                                ///Upload CR.alpha
                                ///

                                if (File.Exists(Application.persistentDataPath + "/Data/CR.alpha"))
                                {
                                    backtoryFile = new BacktoryFile(Application.persistentDataPath + "/Data/CR.alpha");
                                    backtoryFile.UploadInBackground("/" + PlayerPrefs.GetString("Username") + "/", true, (r) =>
                                    {
                                        if (r.Successful)
                                        {
                                            LoadingPanel.SetActive(false);

                                            string filePathOnServer = response.Body;
                                            Debug.Log("Upload was successful. File path on server (url) is " + filePathOnServer);
                                        }
                                        else
                                        {
                                            Debug.Log("failed; " + response.Message + " " + response.Code);
                                            LoadingPanel.SetActive(false);
                                        }
                                    });
                                }
                            }
                            else
                            {
                                Debug.Log("failed; " + response.Message + " " + response.Code);
                                LoadingPanel.SetActive(false);
                            }
                        });
                    }
                }
                else
                {
                    Debug.Log("failed; " + response.Message + " " + response.Code);
                    LoadingPanel.SetActive(false);
                }
            });
        }
    }
Exemple #3
0
        public void uploadFile()
        {
            filePathOnDevice = Path.Combine(Application.persistentDataPath, "tmp.txt");
            File.WriteAllText(filePathOnDevice, fileContentInput.text);
            var bf = new BacktoryFile(filePathOnDevice);

            bf.UploadInBackground(serverFilePathInput.text, true, (response) => {
                ResultText.text = response.Successful ? "Upload file succeeded.\n" +
                                  JsonConvert.SerializeObject(response.Body, Formatting.Indented, JsonnetSetting()) : "failed; " + response.Message;
            });
        }
Exemple #4
0
 public void deleteFile()
 {
     BacktoryFile.DeleteInBackground(serverFilePathInput.text, false, (response) => {
         ResultText.text = response.Successful ? "Delete file succeeded." : "failed; " + response.Message;
     });
 }