GetGlobalCDNUrl
tip
This method was added to support clients (like very old versions of Unity - i.e. circa 2016) that cannot handle HTTP Redirects. This method allows clients to pre-resolve the CDN endpoint for the file to download.
This call is not required in the great majority of cases. Just use the regular file download URL and the platform will automatically re-direct the client to the appropriate CDN URL.
Returns the CDN URL for the specified file.
Service | Operation |
---|---|
globalFileV3 | GET_GLOBAL_CDN_URL |
Method Parameters
Parameter | Description |
---|---|
fileId | File ID |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string fileId = "hjvfsghguhuhrtghgh";
SuccessCallback successCallback = (response, cbObject) =>
{
Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("Failed | {0} {1} {2}", status, code, error));
};
_bc.GlobalFileService.GetGlobalCDNUrl(fileId, successCallback, failureCallback);
const char *fileId = "hjvfsghguhuhrtghgh";
_bc->getGlobalFileService()->getGlobalCDNUrl(fileId, this);
NSString *fileId = @"hjvfsghguhuhrtghgh";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc globalFileService] getGlobalCDNUrl:fileId
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String fileId = "hjvfsghguhuhrtghgh";
this; // implements IServerCallback
_bc.getGlobalFileService().getGlobalCDNUrl(fileId, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var fileId = "hjvfsghguhuhrtghgh";
_bc.globalFile.getGlobalCDNUrl(fileId, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var fileId = "hjvfsghguhuhrtghgh";
ServerResponse result = await _bc.globalFileV3Service.getGlobalCDNUrl(fileId:fileId);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var fileId = "hjvfsghguhuhrtghgh";
var globalFileProxy = bridge.getGlobalFileV3ServiceProxy();
var postResult = globalFileProxy.getGlobalCDNUrl(fileId);
if (postResult.status == 200) {
// Success!
}
{
"service": "globalFileV3",
"operation": "GET_GLOBAL_CDN_URL",
"data": {
"fileId": "hjvfsghguhuhrtghgh"
}
}
JSON Response
{
"status": 200,
"data": {
"appServerUrl": "https://api.braincloudservers.com/...f434b1db538b/f/uploadsimplefile.txt",
"cdnUrl": "https://d2b6zwnvr1nyug.cloudfront.net/bc/g/20001/u/107b3aa9-0d9f-4e90-af..."
}
}