Skip to main content
Version: 5.7.0

UploadFile

Prepares a user file upload. On success the file will begin uploading to the brainCloud server.

To be informed of success/failure of the upload register the File Upload Callbacks with the BrainCloudClient class.

ServiceOperation
filePREPARE_USER_UPLOAD

Method Parameters

ParameterDescription
cloudPathThe desired cloud path of the file
cloudFilenameThe desired cloud fileName of the file
shareableTrue if the file is shareable
replaceIfExistsWhether to replace file if it exists
localPathThe path and fileName of the local file

Usage

http://localhost:3000
_bc.RegisterFileUploadCallbacks(FileCallbackSuccess, FileCallbackFail);

string cloudPath = "test/files/"
string cloudName = "testCloudFile.dat"
bool overwrite = true;
bool share = true;
string localPath = "path/to/my/file.dat";

_bc.FileService.UploadFile(
cloudPath,
cloudName,
share,
overwrite,
localPath,
ApiSuccess, ApiError);
JSON Response
{
"status": 200,
"data": {
"fileDetails": {
"updatedAt": 1452616408147,
"fileSize": 100,
"fileType": "User",
"expiresAt": 1452702808146,
"shareable": true,
"uploadId": "cf9a075c-587e-4bd1-af0b-eab1a79b958f",
"createdAt": 1452616408147,
"profileId": "bf8a1433-62d2-448e-b396-f3dbffff44",
"gameId": "99999",
"path": "dir1/dir2",
"filename": "filename",
"replaceIfExists": true,
"cloudPath": "bc/g/99999/u/bf8a1433-62d2-448e-b396-f3dbffff44/f/dir1/dir2/filename"
}
}
}
Common Error Code

Status Codes

CodeNameDescription
40429UPLOAD_FILE_TOO_LARGEFile maximum file size exceeded
40430FILE_ALREADY_EXISTSFile exists, replaceIfExists not set