mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 14:45:51 +03:00
UgcEditor ContentFolder
This commit is contained in:
parent
f2ae791e15
commit
e275b209b3
@ -29,6 +29,53 @@ public async Task CreateFile()
|
|||||||
Assert.IsTrue( deleted );
|
Assert.IsTrue( deleted );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async Task UploadBigFile()
|
||||||
|
{
|
||||||
|
|
||||||
|
var created = Ugc.Editor.NewCommunityFile
|
||||||
|
.WithTitle( "Unit Test Upload Item" )
|
||||||
|
.WithDescription( "This item was created by Facepunch Steamworks unit tests.\n\n" +
|
||||||
|
"It should have technically been deleted so you should never get to " +
|
||||||
|
"read this unless something terrible has happened." )
|
||||||
|
//.WithTag( "Apple" )
|
||||||
|
//.WithTag( "Banana" )
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
// Make a folder
|
||||||
|
var testFolder = new System.IO.DirectoryInfo( "WorkshopUpload" );
|
||||||
|
if ( !testFolder.Exists ) testFolder.Create();
|
||||||
|
|
||||||
|
created = created.WithContent( testFolder.FullName );
|
||||||
|
|
||||||
|
// Upload a file of random bytes
|
||||||
|
var rand = new Random();
|
||||||
|
var testFile = new byte[1024 * 1024 * 256];
|
||||||
|
rand.NextBytes( testFile );
|
||||||
|
System.IO.File.WriteAllBytes( testFolder.FullName + "/testfile1.bin", testFile );
|
||||||
|
|
||||||
|
Console.WriteLine( testFolder.FullName );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var done = await created.SubmitAsync();
|
||||||
|
|
||||||
|
// TODO - Upload Progress
|
||||||
|
|
||||||
|
Assert.IsTrue( done.Success );
|
||||||
|
Console.WriteLine( "item.Id: {0}", done.FileId );
|
||||||
|
|
||||||
|
var deleted = await SteamUGC.DeleteFileAsync( done.FileId );
|
||||||
|
Assert.IsTrue( deleted );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
System.IO.File.Delete( testFolder.FullName + "/testfile.bin" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,16 @@ internal Editor( WorkshopFileType filetype ) : this()
|
|||||||
string Description;
|
string Description;
|
||||||
public Editor WithDescription( string t ) { this.Description = t; return this; }
|
public Editor WithDescription( string t ) { this.Description = t; return this; }
|
||||||
|
|
||||||
|
string MetaData;
|
||||||
|
public Editor WithMetaData( string t ) { this.MetaData = t; return this; }
|
||||||
|
|
||||||
|
string Language;
|
||||||
|
public Editor InLanguage( string t ) { this.Language = t; return this; }
|
||||||
|
|
||||||
|
System.IO.DirectoryInfo ContentFolder;
|
||||||
|
public Editor WithContent( System.IO.DirectoryInfo t ) { this.ContentFolder = t; return this; }
|
||||||
|
public Editor WithContent( string folderName ) { return WithContent( new System.IO.DirectoryInfo( folderName ) ); }
|
||||||
|
|
||||||
|
|
||||||
public async Task<PublishResult> SubmitAsync()
|
public async Task<PublishResult> SubmitAsync()
|
||||||
{
|
{
|
||||||
@ -83,6 +93,9 @@ public async Task<PublishResult> SubmitAsync()
|
|||||||
|
|
||||||
if ( Title != null ) SteamUGC.Internal.SetItemTitle( handle, Title );
|
if ( Title != null ) SteamUGC.Internal.SetItemTitle( handle, Title );
|
||||||
if ( Description != null ) SteamUGC.Internal.SetItemDescription( handle, Description );
|
if ( Description != null ) SteamUGC.Internal.SetItemDescription( handle, Description );
|
||||||
|
if ( MetaData != null ) SteamUGC.Internal.SetItemMetadata( handle, MetaData );
|
||||||
|
if ( Language != null ) SteamUGC.Internal.SetItemUpdateLanguage( handle, Language );
|
||||||
|
if ( ContentFolder != null ) SteamUGC.Internal.SetItemContent( handle, ContentFolder.FullName );
|
||||||
|
|
||||||
result.Result = Steamworks.Result.Fail;
|
result.Result = Steamworks.Result.Fail;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user