async public static Task <bool> UploadFile(string titleId, DownloadedFile fileInfo) { var currentPlayFabTitleId = PlayFabSettings.TitleId; var currentDevKey = PlayFabSettings.DeveloperSecretKey; var title = FindTitle(titleId); PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = title.SecretKey; var key = fileInfo.FilePath.Split('/').ToList()[fileInfo.FilePath.Split('/').ToList().Count - 1]; var type = MimeMapping.GetMimeMapping(key); var result = await PlayFabAdminAPI.GetContentUploadUrlAsync( new GetContentUploadUrlRequest() { Key = fileInfo.Data.Key, ContentType = type } ); if (result.Error != null) { Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error)); return(false); } PlayFabSettings.TitleId = currentPlayFabTitleId; PlayFabSettings.DeveloperSecretKey = currentDevKey; bool success = await PlayFabExtensions.UploadFile(result.Result.URL, fileInfo.FilePath); if (!success) { return(false); } return(true); }
public static void UploadFile(string titleId, CdnFileDataMigration.UploadFile fileInfo, Action <bool> callback) { var currentPlayFabTitleId = PlayFabSettings.TitleId; var currentDevKey = PlayFabSettings.DeveloperSecretKey; var title = FindTitle(titleId); PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = title.SecretKey; var key = fileInfo.FilePath.Split('/').ToList()[fileInfo.FilePath.Split('/').ToList().Count - 1]; var type = MimeMapping.GetMimeMapping(key); PlayFabAdminAPI.GetContentUploadUrlAsync(new GetContentUploadUrlRequest() { Key = fileInfo.Data.Key, ContentType = type }).ContinueWith((result) => { PlayFabSettings.TitleId = currentPlayFabTitleId; PlayFabSettings.DeveloperSecretKey = currentDevKey; PlayFabExtensions.UploadFile(result.Result.Result.URL, fileInfo.FilePath, callback); }); }