Serenity: Blank Attachment file (0 kb) gives warning

Created on 6 Mar 2018  路  5Comments  路  Source: serenity-is/Serenity

If a user unconsciously uploads a blank file (0 kb) in either Single or Multiple file uploader,
then following warning dialog appears.

Specified argument was out of range of valid values
Parameter name: ImageCheckResult

image

ref: https://github.com/volkanceylan/Serenity/issues/1130

Most helpful comment

Do you have try to add MinSize = 1kb to Attribute MultipleFileUploadEditor?

All 5 comments

Do you have try to add MinSize = 1kb to Attribute MultipleFileUploadEditor?

Thanks, @hairangsua , it works for me...

after applying MinSize it prevents me to upload empty files But it does not allow to upload non-image files larger than 1kd, why? any idea.

[FileUploadEditor(AllowNonImage = true, MinSize = 64]

We have MaxSize in Attribute MultipleFileUploadEditor too. U have not try it. If it not work. u can try this.
This function help me upload to Mongo DB. hope it work.

 private bool Upload(MyRow row)
    {
        var temporyPath = UploadHelper.TemporaryPath;
        var json = row.Images;
        var lstImage = JsonHelper.Parse<List<ImageUploadInfo>>(json);

        int len = lstImage.Count;
        if (len > 3)
        {
            throw new BaseException(Texts.AssetManagement.ItemMaxImageCountReached);
        }
        var count = 0;
        foreach (var i in lstImage)
        {
            count++;
            var f = FileHelper.GetFileFolderName(i.Filename);
            var cfgPath = Path.Combine(temporyPath, f);
            var fData = FileHelper.LoadFile(cfgPath);

            //Size of your file
            if (fData.Length > 1024)
            {
                throw new System.Exception("");
            }
        }
        return true;
    }

Closing due to inactivity.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Shraddha996 picture Shraddha996  路  3Comments

Pinellus picture Pinellus  路  3Comments

JohnRanger picture JohnRanger  路  3Comments

john20xdoe picture john20xdoe  路  3Comments

ga5tan picture ga5tan  路  3Comments