Example #1
0
 internal static void CacheFile(ES3Settings settings)
 {
     if (!ES3.FileExists(settings))
     {
         throw new FileNotFoundException("Could not cache file " + settings.path + " because it does not exist");
     }
     cachedFiles[settings.path] = new ES3File(ES3.LoadRawBytes(settings));
 }
Example #2
0
 public override void Enter()
 {
     if (useBase64Encoding.Value)
     {
         str.Value = System.Convert.ToBase64String(ES3.LoadRawBytes(GetSettings()));
     }
     else
     {
         str.Value = ES3.LoadRawString(GetSettings());
     }
 }
    internal static void CacheFile(ES3Settings settings)
    {
        // If we're still using cached settings, default to file.
        if (settings.location == ES3.Location.Cache)
        {
            settings          = (ES3Settings)settings.Clone();
            settings.location = ES3.Location.File;
        }

        if (!ES3.FileExists(settings))
        {
            return;
        }
        cachedFiles[settings.path] = new ES3File(ES3.LoadRawBytes(settings));
    }
Example #4
0
    /// <summary>Uploads a local file to the server, overwriting any existing file.</summary>
    /// <param name="settings">The settings we want to use to override the default settings.</param>
    /// <param name="user">The unique name of the user this file belongs to, if the file isn't globally accessible.</param>
    /// <param name="password">The password of the user this file belongs to.</param>
    private IEnumerator UploadFile(ES3Settings settings, string user, string password)
    {
        Reset();

        var form = CreateWWWForm();

        form.AddField("apiKey", apiKey);
        form.AddField("putFile", settings.path);
        form.AddField("timestamp", DateTimeToUnixTimestamp(ES3.GetTimestamp(settings)).ToString());
        form.AddField("user", GetUser(user, password));
        form.AddBinaryData("data", ES3.LoadRawBytes(settings), "data.dat", "multipart/form-data");

        using (var webRequest = UnityWebRequest.Post(url, form))
        {
            yield return(webRequest.Send());

            HandleError(webRequest, true);
        }

        isDone = true;
    }
Example #5
0
    internal static void CacheFile(ES3Settings settings)
    {
        // If we're still using cached settings, default to file.
        if (settings.location == ES3.Location.Cache)
        {
            settings          = (ES3Settings)settings.Clone();
            settings.location = ES3.Location.File;
        }

        if (!ES3.FileExists(settings))
        {
            return;
        }


        // Disable compression when loading the raw bytes, and the ES3File constructor will expect compressed bytes.
        var loadSettings = (ES3Settings)settings.Clone();

        loadSettings.compressionType = ES3.CompressionType.None;

        cachedFiles[settings.path] = new ES3File(ES3.LoadRawBytes(loadSettings), settings);
    }
Example #6
0
 /// <summary>Uploads a local file to the server, overwriting any existing file.</summary>
 /// <param name="es3File">An ES3File containing the data we want to upload.</param>
 /// <param name="user">The unique name of the user this file belongs to, if the file isn't globally accessible.</param>
 /// <param name="password">The password of the user this file belongs to.</param>
 public IEnumerator UploadFile(ES3Settings settings, string user, string password)
 {
     return(UploadFile(ES3.LoadRawBytes(settings), settings, user, password));
 }
Example #7
0
 /// <summary>Loads a PNG or JPG as a Texture2D.</summary>
 /// <param name="settings">The settings we want to use to override the default settings.</param>
 public static Texture2D LoadImage(ES3Settings settings)
 {
     byte[] bytes = ES3.LoadRawBytes(settings);
     return(LoadImage(bytes));
 }
Example #8
0
    /// <summary>Loads the default file as a byte array.</summary>
    /// <param name="settings">The settings we want to use to override the default settings.</param>
    public static string LoadRawString(ES3Settings settings)
    {
        var bytes = ES3.LoadRawBytes(settings);

        return(settings.encoding.GetString(bytes, 0, bytes.Length));
    }
Example #9
0
 private IEnumerator UploadFile(byte[] bytes, ES3Settings settings, string user, string password)
 {
     return(UploadFile(ES3.LoadRawBytes(settings), settings, user, password, DateTimeToUnixTimestamp(ES3.GetTimestamp(settings))));
 }