static async Task UploadIcon(Stream iconStream) { var hash = SHAHash(iconStream); var iconSuccess = await CloudStream.UploadStream("gmpublish_icon.jpg", APPID, hash, iconStream.Length, steamClient, iconStream); if (!iconSuccess) { Console.WriteLine("JPG Upload failed"); Exit(32); } }
static async Task UploadAddonGMA(Stream gmaStream) { var lzmaStream = LZMAEncodeStream.CompressStreamLZMA(gmaStream); var hashGma = SHAHash(lzmaStream); var gmaSuccess = await CloudStream.UploadStream("gmpublish.gma", APPID, hashGma, lzmaStream.Length, steamClient, lzmaStream); if (!gmaSuccess) { Console.WriteLine("GMA Upload failed"); Exit(32); } }
static void FullyLoggedIn(SteamUser.LoggedOnCallback callback) { var task = Task.Run(async() => { try { await CloudStream.DeleteFile("gmpublish_icon.jpg", APPID, steamClient); await CloudStream.DeleteFile("gmpublish.gma", APPID, steamClient); var baseFolder = "./Addon"; var gmaPath = "./addon.gma"; //Path.GetTempFileName(); var addonJsonPath = Path.Combine(baseFolder, "addon.json"); if (!File.Exists(addonJsonPath)) { throw new Exception("No addon.json file found in specified folder"); } AddonJSON addon; using (FileStream addonStream = new FileStream(addonJsonPath, FileMode.Open)) { addon = addonStream.CreateFromJsonStream <AddonJSON>(); } if (addon.Icon == "") { throw new Exception("No icon file specified"); } using (Stream gmaStream = new FileStream(gmaPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) { GMADCreator.Create(baseFolder, addon, gmaStream); gmaStream.Seek(0, SeekOrigin.Begin); using (var icon = new FileStream(Path.Combine(baseFolder, addon.Icon), FileMode.Open)) { var hash = SHAHash(icon); var iconSuccess = await CloudStream.UploadStream("gmpublish_icon.jpg", APPID, hash, icon.Length, steamClient, icon); if (!iconSuccess) { Console.WriteLine("JPG Upload failed"); return; } } var lzmaStream = LZMAEncodeStream.CompressStreamLZMA(gmaStream); var hashGma = SHAHash(lzmaStream); var gmaSuccess = await CloudStream.UploadStream("gmpublish.gma", APPID, hashGma, lzmaStream.Length, steamClient, lzmaStream); if (!gmaSuccess) { Console.WriteLine("GMA Upload failed"); return; } } var publishService = steamUnifiedMessages.CreateService <IPublishedFile>(); if (addon.WorkshopID == 0) { var request = new CPublishedFile_Publish_Request { appid = APPID, consumer_appid = APPID, cloudfilename = "gmpublish.gma", preview_cloudfilename = "gmpublish_icon.jpg", title = addon.Title, file_description = addon.Description, file_type = (uint)EWorkshopFileType.Community, visibility = (uint)EPublishedFileVisibility.Public, collection_type = addon.Type, }; foreach (var tag in addon.Tags) { request.tags.Add(tag); } var publishCallback = await publishService.SendMessage(publish => publish.Publish(request)); var publishResponse = publishCallback.GetDeserializedResponse <CPublishedFile_Publish_Response>(); addon.WorkshopID = publishResponse.publishedfileid; using (FileStream addonStream = new FileStream(addonJsonPath, FileMode.Create)) { addonStream.WriteObjectToStreamJson(addon); } Console.WriteLine("NEW PUBLISHED ID: " + publishResponse.publishedfileid + ". Wrote to addon.json"); } else { var request = new CPublishedFile_Update_Request { image_height = 512, image_width = 512, publishedfileid = addon.WorkshopID, appid = APPID, filename = "gmpublish.gma", preview_filename = "gmpublish_icon.jpg", title = addon.Title, file_description = addon.Description, visibility = (uint)EPublishedFileVisibility.Public, }; foreach (var tag in addon.Tags) { request.tags.Add(tag); } var updateCallback = await publishService.SendMessage(publish => publish.Update(request)); var updateResponse = updateCallback.GetDeserializedResponse <CPublishedFile_Update_Response>(); Console.WriteLine("Addon has been updated"); } } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }); task.Wait(); steamUser.LogOff(); isRunning = false; }