Upload
public BackendReturnObject Upload(string collectionName, string jsonString);\ public BackendReturnObject Upload(string collectionName, Param param);
Parameters
Value | Type | Description |
---|---|---|
collectionName | string | Name of the collection where the data will be uploaded |
jsonString | string | Saved data in JSON string format |
param | Param | Saved data in param string format |
Description
Uploads the saved data to the cloud storage.
- The collection must be created in advance via the console.
- Only strings in JSON format can be stored.
- Each collection can only store one piece of data. If there is existing data, it will be overwritten with the new data.
- The maximum storage capacity for each data entry is 1MB.
Example
Synchronous
Case 1
var bro = Backend.CloudSave.Upload("collectionName", jsonString);
if(bro.IsSuccess())
{
// When the request is successful, writes processing code.
}
Case 2
// sample data class
public class SampleUnit
{
public string className;
public int level;
public double Power { get; set; }
}
...
var archer = new SampleUnit()
{
className = "archer", level = 44, Power = 34534.59
};
var param = new Param();
param.Add("user_name", "backend");
param.Add("stage_clear", 1024);
param.Add("archer", archer);
var bro = Backend.CloudSave.Upload("collectionName", param);
if(bro.IsSuccess())
{
// When the request is successful, writes processing code.
}
Asynchronous
Case 1
Backend.CloudSave.Upload("collectionName", jsonString, bro =>
{
if(bro.IsSuccess())
{
// When the request is successful, writes processing code.
}
});
Case 2
// sample data class
public class SampleUnit
{
public string className;
public int level;
public double Power { get; set; }
}
...
var archer = new SampleUnit()
{
className = "archer", level = 44, Power = 34534.59
};
var param = new Param();
param.Add("user_name", "backend");
param.Add("stage_clear", 1024);
param.Add("archer", archer);
Backend.CloudSave.Upload("collectionName", param, bro =>
{
if(bro.IsSuccess())
{
// When the request is successful, writes processing code.
}
});
ReturnCase
Success cases
When uploaded successfully\ StatusCode : 204\ Message : Success
Error cases
When the data is not in JSON format\ StatusCode : 400\ ErrorCode : ValidationException\ Message : Failed to parse the string into JSON.
When the data size exceeds the limit\ StatusCode : 400\ ErrorCode : ValidationException\ Message : The string size is too big.
When the collection does not exist\ StatusCode : 404\ Message : not exist folder\ Code : NotFound