Check if file is exceeding maximum http upload size.

http_upload
Martin Dosch 4 years ago
parent 854cff096e
commit 0d6d4a5479

@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
// TODO:
// * Check filesize limit before trying to send
// * Check IQ replies for type='error'
// * Update Manpages
@ -163,6 +162,15 @@ func httpUpload(client *xmpp.Client, jserver string, filePath string) string {
if uploadComponent == "" {
log.Fatal("No http upload component found.")
}
maxFileSize, err := strconv.ParseInt(iqDiscoInfoXML.X[1].Field[1].Value, 10, 64)
if err != nil {
log.Fatal("Error while checking server maximum http upload file size.")
}
if fileSize > maxFileSize {
log.Fatal("File size " + strconv.FormatInt(fileSize/1024/1024, 10) +
" MB is larger than the maximum file size allowed (" +
strconv.FormatInt(maxFileSize/1024/1024, 10) + " MB).")
}
// Request http upload slot
id = getID()

Loading…
Cancel
Save