@@ -1284,8 +1284,7 @@ public static void UploadPlayerFile(string pathToFile, string filePurpose, bool
1284
1284
LootLockerResponse . Serialize ( onComplete , serverResponse ) ;
1285
1285
} ) ;
1286
1286
}
1287
-
1288
- ///
1287
+
1289
1288
/// <summary>
1290
1289
/// Upload a file with the provided name and content. The file will be owned by the player with the provided playerID.
1291
1290
/// It will not be viewable by other players.
@@ -1376,7 +1375,7 @@ public static void UploadPlayerFile(byte[] fileBytes, string fileName, string fi
1376
1375
LootLockerResponse . Serialize ( onComplete , serverResponse ) ;
1377
1376
} ) ;
1378
1377
}
1379
-
1378
+
1380
1379
/// <summary>
1381
1380
/// Upload a file using a byte array. Can be useful if you want to upload without storing anything on disk. The file will be owned by the currently active player.
1382
1381
/// </summary>
@@ -1388,6 +1387,99 @@ public static void UploadPlayerFile(byte[] fileBytes, string fileName, string fi
1388
1387
{
1389
1388
UploadPlayerFile ( fileBytes , fileName , filePurpose , false , onComplete ) ;
1390
1389
}
1390
+
1391
+ ///////////////////////////////////////////////////////////////////////////////
1392
+
1393
+ /// <summary>
1394
+ /// Update an existing player file with a new file.
1395
+ /// </summary>
1396
+ /// <param name="fileId">Id of the file. You can get the ID of files when you upload a file, or with GetAllPlayerFiles()</param>
1397
+ /// <param name="pathToFile">Path to the file, example: Application.persistentDataPath + "/" + fileName;</param>
1398
+ /// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerFile</param>
1399
+ public static void UpdatePlayerFile ( int fileId , string pathToFile , Action < LootLockerPlayerFile > onComplete )
1400
+ {
1401
+ if ( ! CheckInitialized ( ) )
1402
+ {
1403
+ onComplete ? . Invoke ( LootLockerResponseFactory . SDKNotInitializedError < LootLockerPlayerFile > ( ) ) ;
1404
+ return ;
1405
+ }
1406
+
1407
+ var fileBytes = new byte [ ] { } ;
1408
+ try
1409
+ {
1410
+ fileBytes = File . ReadAllBytes ( pathToFile ) ;
1411
+ }
1412
+ catch ( Exception e )
1413
+ {
1414
+ LootLockerLogger . GetForLogLevel ( LootLockerLogger . LogLevel . Error ) ( $ "File error: { e . Message } ") ;
1415
+ return ;
1416
+ }
1417
+
1418
+ var endpoint = string . Format ( LootLockerEndPoints . updatePlayerFile . endPoint , fileId ) ;
1419
+
1420
+ LootLockerServerRequest . UploadFile ( endpoint , LootLockerEndPoints . updatePlayerFile . httpMethod , fileBytes , Path . GetFileName ( pathToFile ) , "multipart/form-data" , new Dictionary < string , string > ( ) ,
1421
+ onComplete : ( serverResponse ) =>
1422
+ {
1423
+ LootLockerResponse . Serialize ( onComplete , serverResponse ) ;
1424
+ } ) ;
1425
+ }
1426
+
1427
+ /// <summary>
1428
+ /// Update an existing player file with a new file using a Filestream. Can be useful if you want to upload without storing anything on disk.
1429
+ /// </summary>
1430
+ /// <param name="fileId">Id of the file. You can get the ID of files when you upload a file, or with GetAllPlayerFiles()</param>
1431
+ /// <param name="fileStream">Filestream to upload</param>
1432
+ /// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerFile</param>
1433
+ public static void UpdatePlayerFile ( int fileId , FileStream fileStream , Action < LootLockerPlayerFile > onComplete )
1434
+ {
1435
+ if ( ! CheckInitialized ( ) )
1436
+ {
1437
+ onComplete ? . Invoke ( LootLockerResponseFactory . SDKNotInitializedError < LootLockerPlayerFile > ( ) ) ;
1438
+ return ;
1439
+ }
1440
+
1441
+ var fileBytes = new byte [ fileStream . Length ] ;
1442
+ try
1443
+ {
1444
+ fileStream . Read ( fileBytes , 0 , Convert . ToInt32 ( fileStream . Length ) ) ;
1445
+ }
1446
+ catch ( Exception e )
1447
+ {
1448
+ LootLockerLogger . GetForLogLevel ( LootLockerLogger . LogLevel . Error ) ( $ "File error: { e . Message } ") ;
1449
+ return ;
1450
+ }
1451
+
1452
+ var endpoint = string . Format ( LootLockerEndPoints . updatePlayerFile . endPoint , fileId ) ;
1453
+
1454
+ LootLockerServerRequest . UploadFile ( endpoint , LootLockerEndPoints . updatePlayerFile . httpMethod , fileBytes , Path . GetFileName ( fileStream . Name ) , "multipart/form-data" , new Dictionary < string , string > ( ) ,
1455
+ onComplete : ( serverResponse ) =>
1456
+ {
1457
+ LootLockerResponse . Serialize ( onComplete , serverResponse ) ;
1458
+ } ) ;
1459
+ }
1460
+
1461
+ /// <summary>
1462
+ /// Update an existing player file with a new file using a byte array. Can be useful if you want to upload without storing anything on disk.
1463
+ /// </summary>
1464
+ /// <param name="fileId">Id of the file. You can get the ID of files when you upload a file, or with GetAllPlayerFiles()</param>
1465
+ /// <param name="fileBytes">Byte array to upload</param>
1466
+ /// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerFile</param>
1467
+ public static void UpdatePlayerFile ( int fileId , byte [ ] fileBytes , Action < LootLockerPlayerFile > onComplete )
1468
+ {
1469
+ if ( ! CheckInitialized ( ) )
1470
+ {
1471
+ onComplete ? . Invoke ( LootLockerResponseFactory . SDKNotInitializedError < LootLockerPlayerFile > ( ) ) ;
1472
+ return ;
1473
+ }
1474
+
1475
+ var endpoint = string . Format ( LootLockerEndPoints . updatePlayerFile . endPoint , fileId ) ;
1476
+
1477
+ LootLockerServerRequest . UploadFile ( endpoint , LootLockerEndPoints . updatePlayerFile . httpMethod , fileBytes , null , "multipart/form-data" , new Dictionary < string , string > ( ) ,
1478
+ onComplete : ( serverResponse ) =>
1479
+ {
1480
+ LootLockerResponse . Serialize ( onComplete , serverResponse ) ;
1481
+ } ) ;
1482
+ }
1391
1483
1392
1484
/// <summary>
1393
1485
/// The file will be deleted immediately and the action can not be reversed. You will get the ID of files when you upload a file, or with GetAllPlayerFiles().
0 commit comments