Skip to main content
Version: 5.18.17

Upload

public BackendReturnObject Upload(string collectionName, string jsonString);

public BackendReturnObject Upload(string collectionName, Param param);

Parameters​

ValueTypeDescription
collectionNamestringName of the collection where the data will be uploaded
jsonStringstringSaved data in JSON string format
paramParamSaved 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.
  • Typically, the response time is around 800 ms. However, it can exceed 2 seconds under heavy throughput.

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