@@ -43,13 +43,10 @@ public partial class FossologyClient
43
43
/// <param name="description">The description.</param>
44
44
/// <param name="accessLevel">The access level.</param>
45
45
/// <param name="ignoreScm">if set to <c>true</c> ignore SCM files.</param>
46
- /// <returns>
47
- /// An <see cref="Result" /> object.
48
- /// </returns>
49
- /// <remarks>
50
- /// The message property of the result contains the upload id
51
- /// which is needed for further operations.
52
- /// </remarks>
46
+ /// <param name="applyGlobal">if set to <c>true</c> apply global decisions.</param>
47
+ /// <returns>An <see cref="Result" /> object.</returns>
48
+ /// <remarks>The message property of the result contains the upload id
49
+ /// which is needed for further operations.</remarks>
53
50
public Result UploadPackage (
54
51
string fileName ,
55
52
int folderId ,
@@ -58,10 +55,16 @@ public Result UploadPackage(
58
55
Action < float > uploadProgress = null ,
59
56
string description = "" ,
60
57
string accessLevel = "public" ,
61
- bool ignoreScm = true )
58
+ bool ignoreScm = true ,
59
+ bool applyGlobal = false )
62
60
{
63
61
Log . Debug ( $ "Uploading package { fileName } to folder { folderId } ...") ;
64
62
63
+ if ( ! File . Exists ( fileName ) )
64
+ {
65
+ throw new FossologyApiException ( ErrorCode . FileNotFound , fileName ) ;
66
+ } // if
67
+
65
68
var request = new RestRequest ( this . Url + "/uploads" , Method . POST ) ;
66
69
request . RequestFormat = DataFormat . Json ;
67
70
request . AddHeader ( "folderId" , folderId . ToString ( ) ) ;
@@ -70,13 +73,14 @@ public Result UploadPackage(
70
73
request . AddHeader ( "public" , accessLevel ) ;
71
74
request . AddHeader ( "ignoreScm" , ignoreScm . ToString ( ) ) ;
72
75
request . AddHeader ( "Content-Type" , "multipart/form-data" ) ;
76
+ request . AddHeader ( "applyGlobal" , applyGlobal . ToString ( ) ) ;
73
77
74
78
var fi = new FileInfo ( fileName ) ;
75
79
var item = new FileParameter
76
80
{
77
81
Name = "fileInput" ,
78
82
ContentLength = fi . Length ,
79
- FileName = fileName ,
83
+ FileName = fi . Name ,
80
84
ContentType = "application/octet-stream" ,
81
85
} ;
82
86
item . Writer = stream =>
0 commit comments