@@ -44,15 +44,8 @@ type FileScanner struct {
44
44
cli * Client
45
45
}
46
46
47
- // Scan sends a file to VirusTotal for scanning. The file content is read from
48
- // the r io.Reader and sent to VirusTotal with the provided file name which can
49
- // be left blank. The function also sends a float32 through the progress channel
50
- // indicating the percentage of the file that has been already uploaded. The
51
- // progress channel can be nil if the caller is not interested in receiving
52
- // upload progress updates. An analysis object is returned as soon as the file
53
- // is uploaded.
54
- func (s * FileScanner ) Scan (r io.Reader , filename string , progress chan <- float32 ) (* Object , error ) {
55
-
47
+ func (s * FileScanner ) scanWithParameters (
48
+ r io.Reader , filename string , progress chan <- float32 , parameters map [string ]string ) (* Object , error ) {
56
49
var uploadURL * url.URL
57
50
var payloadSize int64
58
51
@@ -70,6 +63,14 @@ func (s *FileScanner) Scan(r io.Reader, filename string, progress chan<- float32
70
63
return nil , err
71
64
}
72
65
66
+ if parameters != nil {
67
+ for key , val := range parameters {
68
+ if err := w .WriteField (key , val ); err != nil {
69
+ return nil , err
70
+ }
71
+ }
72
+ }
73
+
73
74
w .Close ()
74
75
75
76
if payloadSize > maxFileSize {
@@ -114,6 +115,38 @@ func (s *FileScanner) Scan(r io.Reader, filename string, progress chan<- float32
114
115
return analysis , nil
115
116
}
116
117
118
+ // ScanParameters sends a file to VirusTotal for scanning. The file content is
119
+ // read from the r io.Reader and sent to VirusTotal with the provided file name
120
+ // which can be left blank. The function also sends a float32 through the
121
+ // progress channel indicating the percentage of the file that has been already
122
+ // uploaded. The progress channel can be nil if the caller is not interested in
123
+ // receiving upload progress updates. An analysis object is returned as soon as
124
+ // the file is uploaded. Additional parameters can be passed to the scan
125
+ // by using the parameters map[string]string argument.
126
+ func (s * FileScanner ) ScanParameters (
127
+ r io.Reader , filename string , progress chan <- float32 , parameters map [string ]string ) (* Object , error ) {
128
+ return s .scanWithParameters (r , filename , progress , parameters )
129
+ }
130
+
131
+ // ScanFileWithParameters sends a file to VirusTotal for scanning. This function
132
+ // is similar to ScanWithParameters but it receives an *os.File instead of a
133
+ // io.Reader and a file name.
134
+ func (s * FileScanner ) ScanFileWithParameters (
135
+ f * os.File , progress chan <- float32 , parameters map [string ]string ) (* Object , error ) {
136
+ return s .scanWithParameters (f , f .Name (), progress , parameters )
137
+ }
138
+
139
+ // Scan sends a file to VirusTotal for scanning. The file content is read from
140
+ // the r io.Reader and sent to VirusTotal with the provided file name which can
141
+ // be left blank. The function also sends a float32 through the progress channel
142
+ // indicating the percentage of the file that has been already uploaded. The
143
+ // progress channel can be nil if the caller is not interested in receiving
144
+ // upload progress updates. An analysis object is returned as soon as the file
145
+ // is uploaded.
146
+ func (s * FileScanner ) Scan (r io.Reader , filename string , progress chan <- float32 ) (* Object , error ) {
147
+ return s .scanWithParameters (r , filename , progress , nil )
148
+ }
149
+
117
150
// ScanFile sends a file to VirusTotal for scanning. This function is similar to
118
151
// Scan but it receive an *os.File instead of a io.Reader and a file name.
119
152
func (s * FileScanner ) ScanFile (f * os.File , progress chan <- float32 ) (* Object , error ) {
0 commit comments