File limits
This commit is contained in:
parent
075b4fce3d
commit
43cfb821b3
@ -107,6 +107,11 @@ CustomUploader::CustomUploader(QString absFilePath) {
|
||||
returnPathspec = returnPsVal.toString();
|
||||
} else
|
||||
error(absFilePath, "return invalid");
|
||||
QJsonValue fileLimit = obj["fileLimit"];
|
||||
if (!fileLimit.isNull() && !fileLimit.isUndefined()) {
|
||||
if (!fileLimit.isDouble()) error(absFilePath, "fileLimit not double");
|
||||
limit = fileLimit.toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
QString CustomUploader::name() {
|
||||
@ -279,6 +284,10 @@ void CustomUploader::doUpload(QPixmap *pixmap) {
|
||||
}
|
||||
} break;
|
||||
}
|
||||
if (limit != -1 && data.size() > limit) {
|
||||
notifications::notify("KShare Custom Uploader " + name(), "File limit exceeded!");
|
||||
return;
|
||||
}
|
||||
switch (method) {
|
||||
case HttpMethod::POST:
|
||||
if (returnPathspec == "|") {
|
||||
|
@ -20,6 +20,7 @@ class CustomUploader : public Uploader {
|
||||
QMap<QString, QString> types;
|
||||
|
||||
private:
|
||||
double limit;
|
||||
QString desc;
|
||||
QString uName;
|
||||
RequestFormat format = RequestFormat::JSON;
|
||||
|
@ -11,6 +11,10 @@ void ImgurUploader::doUpload(QPixmap *pixmap) {
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
pixmap->save(&buffer, "PNG");
|
||||
if (buffer.size() > 1e+7) {
|
||||
notifications::notify("KShare imgur Uploader ", "Failed upload! Image too big");
|
||||
return;
|
||||
}
|
||||
ioutils::postJson(QUrl("https://api.imgur.com/3/image"),
|
||||
QList<QPair<QString, QString>>()
|
||||
<< QPair<QString, QString>("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
Loading…
Reference in New Issue
Block a user