Error saving editor form after uploading files - Page 2

Error saving editor form after uploading files

2

Answers

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Thank you. Will try that.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Hi

    I added the leftjoin following your recommendation above. Maybe I got that wrong. Removing the leftjoin gives me the error below:

    System.ArgumentException
    HResult=0x80070057
    Message=An item with the same key has already been added.
    Source=mscorlib
    StackTrace:
    at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
    at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
    at DataTables.Editor._InsertOrUpdateTable(String table, Dictionary2 values, Dictionary2 where) in /home/vagrant/DataTablesSrc/extensions/Editor-NET/DataTables-Editor-Server/Editor.cs:line 2204

    After selecting the files for upload entries get created in UserFiles. It looks like it's trying to add them again after clicking save.

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Let's go back to this:

    So I guess we need to consider, is one-to-one what you want? If so, don't use an Mjoin, use a left join.

    You want to use either a left join and an Mjoin. Not both.

    So the question is, do you want one UserFiles entry per AutoCDRFiles entry or multiple?

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Hi

    Yes it is one UserFiles entry per AutoCDRFiles entry. Thanks.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Would you have any news on this please?

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Apologies - I missed your reply before. If its a single entry, then a left join is the way to go and an Mjoin is not required at all.

    Let's try this:

            editor = new Editor(db, "AutoCDRFiles");
            editor.Model<CDRDataDBModel>("AutoCDRFiles");
            editor.Field(new Field("AutoCDRFiles.id")
                .Set(false)
            );
            editor.Field(new Field("AutoCDRFiles.UserFileID")
                        .SetFormatter(Format.IfEmpty(0))
                        .Upload(new Upload(strFolder + "__NAME____EXTN__")
                        .Db("UserFiles", "ID", new Dictionary<string, object>
                        {
                            {"WebPath", Upload.DbType.WebPath},
                            {"SystemPath", Upload.DbType.SystemPath},
                            {"FileName", Upload.DbType.FileName},
                            {"FileSize", Upload.DbType.FileSize}
                        })
                    )
                )
            );
            editor.LeftJoin("UserFiles", "UserFiles.id", "=", "AutoCDRFiles.UserFileID");
    

    That will read the data from your AutoCDRFiles (the model) and also UserFiles for the left join.

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Many thanks. Will try that.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Many thanks. Will try that.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Hi

    Thanks for your patience with this.

    Test #1:

    If I use below code for the upload and create processes, I am able to upload the files. UserFiles table gets populated with the files but when saving (ie create stage) from editor I get error below. AutoCDRFiles table does not show any record.

    Error:

    System.NullReferenceException
    HResult=0x80004003
    Message=Object reference not set to an instance of an object.
    Source=DataTables-Editor-Server
    StackTrace:
    at DataTables.MJoin.Insert(Editor editor, Object parentId, Dictionary`2 data) in /home/vagrant/DataTablesSrc/extensions/Editor-NET/DataTables-Editor-Server/MJoin.cs:line 510

    Code:

    editor.MJoin(new MJoin("AutoCDRFiles")
        .Link("UserFiles.id", "AutoCDRFiles.UserFileID")
        .Order("AutoCDRFiles.id ASC")
        .Field(new Field("UserFileID")
            .SetFormatter(Format.IfEmpty(0))
            .Upload(new Upload(strFolder + "__NAME____EXTN__")
                .Db("UserFiles", "id", new Dictionary<string, object>
                {
                        {"WebPath", Upload.DbType.WebPath},
                        {"SystemPath", Upload.DbType.SystemPath},
                        {"FileName", Upload.DbType.FileName},
                        {"FileSize", Upload.DbType.FileSize}
                })
                .Validator(Validation.FileExtensions(CommonUtilities.CorrectFileTypes(2), lblo.lblInvalidFileType))
            )
        )
    );
    

    Test #2:

    If I use the code you last gave me for the upload and create processes, uploading stumbles and I get error below. There is nothing in either table. I confirm it is a 1-1 relation I need but it seems this is missing something as at least the files get uploaded with the MJoin code above.

    Error:

    System.Exception
    HResult=0x80131500
    Message=Unknown upload field name submitted
    Source=DataTables-Editor-Server
    StackTrace:
    at DataTables.Editor._Upload(DtRequest data) in /home/vagrant/DataTablesSrc/extensions/Editor-NET/DataTables-Editor-Server/Editor.cs:line 1659

    Code:

    editor.Field(new Field("AutoCDRFiles.UserFileID")
        .SetFormatter(Format.IfEmpty(0))
        .Upload(new Upload(strFolder + "__NAME____EXTN__")
            .Db("UserFiles", "id", new Dictionary<string, object>
            {
                {"WebPath", Upload.DbType.WebPath},
                {"SystemPath", Upload.DbType.SystemPath},
                {"FileName", Upload.DbType.FileName},
                {"FileSize", Upload.DbType.FileSize}
            })
            .Validator(Validation.FileExtensions(CommonUtilities.CorrectFileTypes(2), lblo.lblInvalidFileType))
        )
    );
    editor.LeftJoin("UserFiles", "UserFiles.id", "=", "AutoCDRFiles.UserFileID");
    

    Test #3:

    If I use a mixture of both, ie 1st code for upload process and 2nd code for create I do get a line in AutoCDRFiles but only for the last file I try to upload and field UserFileID, holding the id from UserFiles is empty.

    Thank you.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    For Test #2, I'm checking for any conflict with the field name in js code.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    I believe the field name is correct "name: 'AutoCDRFiles[].UserFileID',"

    Code:

                destroy: true,
                ajax: {
                    url: '/CDRData/CRUDCDRDataAndFiles/',
                    data: function (d) {
                        if (d.action != undefined) {
                            if (d.action == "create") {
                                strEditorState1 = "create";
                            }
                        }
                        return $.extend({}, d, {
                            intCdrFrmtSrc: intCdrFrmtSrc1,
                            intCdrFrmtTpe: intCdrFrmtTpe1,
                            strCdrFrmtNme: strCdrFrmtNme1,
                            strCdrFileNme: strCdrFileNme1,
                            strEditorState: strEditorState1
                        });
                    },
                    type: 'POST',
                    async: true,
                    cache: false
                },
                table: '#tblCDRDataAndFilesTable',
                fields: [
                    {
                        label: '@(lblo.lblFormatSource):',
                        name: 'AutoCDRFiles.CDRSourceType',
                        type: 'select',
                        options: [
                            ...
                        ],
                        def: '0'
                        //def: 'default'
                    }, {
                        label: '@(lblo.lblFormatType)*:',
                        name: 'AutoCDRFiles.CDRDataType',
                        id: 'CDRDataType_id',
                        type: 'select',
                        options: [
                            ...
                        ],
                        def: '-1'
                        //def: 'default'
                    }, {
                        label: '@(lblo.lblFormatName)*:',
                        name: 'AutoCDRFiles.CDRName',
                        type: 'select',
                        options: [
    
                        ],
                        def: 'default'
                    }, {
                        label: '@(lblo.lblUploadedFile)*:',
                        name: 'AutoCDRFiles[].UserFileID',
                        type: 'uploadMany',
                        //conf.ajaxData( data, files[ counter ], counter );
                        display: function (fileId, counter) {
                            strCdrFileNme1 = editor1.file('UserFiles', fileId).FileName;
                            return fileId ? GetEditorUploadFileRender(editor1.file( 'UserFiles', fileId ).WebPath, editor1.file( 'UserFiles', fileId ).FileName, 1, '@strFileIconWebPath') : null;
                        },
                        clearText: '@(lblo.lblClear)',
                        noFileText: '@(lblo.lblNoFile)'
                    }
                ],
                i18n: {
                    ...
                }
            });
    
  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    If I cange from uploadMany to upload and modify what is needed in the code everything works. I'm pretty sure the issue is the field name under

    editor.Field(new Field("AutoCDRFiles.UserFileID")

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    If I use .Field(new Field("AutoCDRFiles[].UserFileID"), upload goes through but saving does not. Error is:
    System.Data.SqlClient.SqlException
    HResult=0x80131904
    Message=Invalid column name 'AutoCDRFiles[].[UserFileID'.
    Source=.Net SqlClient Data Provider
    StackTrace:
    <Cannot evaluate the exception stack trace>

    I'd be grateful for a reply as I really wish to move on from this issue.

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Let's go with test #2 as its a 1:1 relationship a leftjoin should be used (its way faster than an Mjoin).

    You are currently getting:

    Message=Unknown upload field name submitted

    Which suggests that the field name on the client-side for the upload is not the same as what you have on the server-side:

    editor.Field(new Field("AutoCDRFiles.UserFileID")

    From the other posts in your thread above, it looks like you might have array syntax in the field name (fields.name) but without being able to see your Javascript I can't say for sure.

    So I's say go to test #2 and check that the field name matches the field that you've attached the Upload to on the server-side.

    Regards,
    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Hi

    I posted the code for js and the field name in "Posts: 183 Questions: 31 Answers: 2 2:13PM":

             label: '@(lblo.lblUploadedFile)*:',
            name: 'AutoCDRFiles[].UserFileID',
            type: 'uploadMany',
            //conf.ajaxData( data, files[ counter ], counter );
            display: function (fileId, counter) {
                strCdrFileNme1 = editor1.file('UserFiles', fileId).FileName;
                return fileId ? GetEditorUploadFileRender(editor1.file( 'UserFiles', fileId ).WebPath, editor1.file( 'UserFiles', fileId ).FileName, 1, '@strFileIconWebPath') : null;
            },
            clearText: '@(lblo.lblClear)',
            noFileText: '@(lblo.lblNoFile)'
    

    If I put name: 'AutoCDRFiles.UserFileID', instead of name: 'AutoCDRFiles[].UserFileID' to match the server side editor.Field(new Field("AutoCDRFiles.UserFileID"), I get:

    System.ArgumentException
    HResult=0x80070057
    Message=No mapping exists from object type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] to a known managed provider native type.
    Source=<Cannot evaluate the exception source>
    StackTrace:
    <Cannot evaluate the exception stack trace>

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    And if I use AutoCDRFiles[].UserFileID in server and client js I get:

    System.Data.SqlClient.SqlException
    HResult=0x80131904
    Message=Invalid column name 'AutoCDRFiles[].[UserFileID'.
    Source=.Net SqlClient Data Provider
    StackTrace:
    <Cannot evaluate the exception stack trace>

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Thanks for the clarification - I'd assumed that the Javascript there was for the Mjoin test. As I say, don't use the array syntax in the field name - use AutoCDRFiles.UserFileID - it has to match the server-side. I also am assuming that you've removed the Mjoin completely from the server-side code (which I'm not certain is the case given that your last post above doesn't just give an 'unknown upload field name' error.

    Could you show me the Javascript code and C# controller that you have with those changes so I'm fully up to date please?

    For reference, this is the file upload example and this is the C# controller for it (available in the demo package):

        public class UploadController : Controller
        {
            [HttpGet, HttpPost, Route("api/upload")]
            public ActionResult Staff()
            {
                var dbType = Environment.GetEnvironmentVariable("DBTYPE");
                var dbConnection = Environment.GetEnvironmentVariable("DBCONNECTION");
    
                using (var db = new Database(dbType, dbConnection))
                {
                    var response = new Editor(db, "users")
                        .Model<UploadModel>()
                                .TryCatch(false)
                        .Field(new Field("image")
                            .SetFormatter(Format.IfEmpty(null))
                            .Upload(new Upload(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "uploads", "__ID____EXTN__"))
                                .Db("files", "id", new Dictionary<string, object>
                                {
                                    {"web_path", Path.DirectorySeparatorChar+Path.Combine("uploads", "__ID____EXTN__")},
                                    {"system_path", Upload.DbType.SystemPath},
                                    {"filename", Upload.DbType.FileName},
                                    {"filesize", Upload.DbType.FileSize}
                                })
                                .DbClean(data =>
                                {
                                    foreach (var row in data)
                                    {
                                        // Do something;
                                    }
                                    return true;
                                })
                                .Validator(Validation.FileSize(500000, "Max file size is 500K."))
                                .Validator(Validation.FileExtensions( new [] {"jpg", "png", "gif"}, "Please upload an image."))
                            )
                        )
                        .Process(Request)
                        .Data();
    
                    return Json(response);
                }
            }
    

    It sounds like you are basically trying to achieve the same thing.

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Yes, I have removed all refs to MJoin. Will post code in a moment. Thanks.

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    JS:

                destroy: true,
                ajax: {
                    url: '/CDRData/CRUDCDRDataAndFiles/',
                    data: function (d) {
                        if (d.action != undefined) {
                            if (d.action == "create") {
                                strEditorState1 = "create";
                            }
                        }
                        return $.extend({}, d, {
                            intCdrFrmtSrc: intCdrFrmtSrc1,
                            intCdrFrmtTpe: intCdrFrmtTpe1,
                            strCdrFrmtNme: strCdrFrmtNme1,
                            strCdrFileNme: strCdrFileNme1,
                            strEditorState: strEditorState1
                        });
                    },
                    type: 'POST',
                    async: true,
                    cache: false
                },
                table: '#tblCDRDataAndFilesTable',
                fields: [
                    {
                        label: '@(lblo.lblFormatSource):',
                        name: 'AutoCDRFiles.CDRSourceType',
                        type: 'select',
                        options: [
                            ...
                        ],
                        def: '0'
                    }, {
                        label: '@(lblo.lblFormatType)*:',
                        name: 'AutoCDRFiles.CDRDataType',
                        id: 'CDRDataType_id',
                        type: 'select',
                        options: [
                            ...
                        ],
                        def: '-1'
                    }, {
                        label: '@(lblo.lblFormatName)*:',
                        name: 'AutoCDRFiles.CDRName',
                        type: 'select',
                        options: [
    
                        ],
                        def: 'default'
                    }, {
                        label: '@(lblo.lblUploadedFile)*:',
                        name: 'AutoCDRFiles.UserFileID',
                        type: 'uploadMany',
                        //conf.ajaxData( data, files[ counter ], counter );
                        display: function (fileId, counter) {
                            strCdrFileNme1 = editor1.file('UserFiles', fileId).FileName;
                            return fileId ? GetEditorUploadFileRender(editor1.file( 'UserFiles', fileId ).WebPath, editor1.file( 'UserFiles', fileId ).FileName, 1, '@strFileIconWebPath') : null;
                        },
                        clearText: '@(lblo.lblClear)',
                        noFileText: '@(lblo.lblNoFile)'
                    }
                ],
                i18n: {...}
                }
            });
    

    Server:

                using (Database db = new Database(SetGetDbType2, SetGetDbConnection))
                {
                    editor = new Editor(db, "AutoCDRFiles").Model<CDRDataDBModel>("AutoCDRFiles");
                    editor.Field(new Field("AutoCDRFiles.id")
                        .Set(false)
                    );
    
                    if (strEditorState == "create" || strEditorState == "upload")
                    {
                        editor.Field(new Field("AutoCDRFiles.CDRSourceType")
                            .GetFormatter((val, host) => Array.Find(arrNVVM1, o => o.intValue == Convert.ToInt16(val)).Text)
                            .Validator((val, d, host) => CommonUtilities.ToString(val) == "-1" ? "Hiya" : null)
                            .SetValue(intCdrFrmtSrc)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRDataType")
                            .GetFormatter((val, host) => Array.Find(arrNVVM2, o => o.intValue == Convert.ToInt16(val)).Text)
                            .Validator((val, d, host) => CommonUtilities.ToString(val) == "-1" ? "Hiya" : null)
                            .SetValue(intCdrFrmtTpe)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRName")
                            .Validator((val, d, host) => CommonUtilities.ToString(val) == "default" ? "Hiya" : null)
                            .SetValue(strCdrFrmtNme)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRFilePath")
                            .SetValue(strFolder)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRFileName")
                            .Validator(Validation.Unique(new ValidationOpts
                            {
                                Message = "Hiya"
                            }))
                            .SetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? null : val)
                            .SetValue(strCdrFileNme)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRFileMarked")
                            .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                            .SetValue(0)
                        );
                        editor.Field(new Field("AutoCDRFiles.DateRated")
                            .GetFormatter((val, data) => CommonUtilities.ToDateTimeString(CommonUtilities.ToDateTime(val), 1))
                            .SetValue(null)
                        );
                        editor.Field(new Field("AutoCDRFiles.DateFile")
                            .GetFormatter((val, data) => CommonUtilities.ToDateTimeString(CommonUtilities.ToDateTime(val), 1))
                            .SetValue(null)
                        );
                        editor.Field(new Field("AutoCDRFiles.RatedStatus")
                            .GetFormatter((val, host) => Array.Find(arrNVVM3, o => o.intValue == Convert.ToInt16(val)).Text)
                            .SetValue(0)
                        );
    
                        editor.LeftJoin("UserFiles", "UserFiles.id", "=", "AutoCDRFiles.UserFileID")
                            .Field(new Field("AutoCDRFiles.UserFileID")
                            .SetFormatter(Format.IfEmpty(0))
                            .Upload(new Upload(strFolder + "__NAME____EXTN__")
                                .Db("UserFiles", "id", new Dictionary<string, object>
                                {
                                    {"WebPath", Upload.DbType.WebPath},
                                    {"SystemPath", Upload.DbType.SystemPath},
                                    {"FileName", Upload.DbType.FileName},
                                    {"FileSize", Upload.DbType.FileSize}
                                })
                                .Validator(Validation.FileExtensions(CommonUtilities.CorrectFileTypes(2), "Hiya"))
                            )
                        );
    
                        //}
                    }
                    else  //load, remove, edit
                    {
                        editor.Field(new Field("AutoCDRFiles.CDRSourceType")
                            .GetFormatter((val, host) => Array.Find(arrNVVM1, o => o.intValue == Convert.ToInt16(val)).Text)
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRDataType")
                            .GetFormatter((val, host) => Array.Find(arrNVVM2, o => o.intValue == Convert.ToInt16(val)).Text)
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRName")
                            .Validator((val, d, host) => CommonUtilities.ToString(val) == "default" ? "Hiya" : null)
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRFilePath")
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRFileName")
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.CDRFileMarked")
                            .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                            .SetFormatter((val, data) => CommonUtilities.ToInt16(val) == -1 ? 0 : val)
                        );
                        editor.Field(new Field("AutoCDRFiles.DateRated")
                            .GetFormatter((val, data) => CommonUtilities.ToDateTimeString(CommonUtilities.ToDateTime(val), 1))
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.DateFile")
                            .GetFormatter((val, data) => CommonUtilities.ToDateTimeString(CommonUtilities.ToDateTime(val), 1))
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.RatedStatus")
                            .GetFormatter((val, host) => Array.Find(arrNVVM3, o => o.intValue == Convert.ToInt16(val)).Text)
                            .Set(false)
                        );
                        editor.Field(new Field("AutoCDRFiles.UserFileID")
                            .Set(false)
                        );
                    }
                    editor.TryCatch(false);
                    editor.Debug(true);
                    editor.Process(formData);
                    editor.Data();
                }
    
  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Can you change:

    type: 'uploadMany',

    To be:

    type: 'upload',
    

    please? As you noted before its 1:1 so it shouldn't use the many uploader.

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Hi

    I think there might be some confusion on my part. As I indicated in this thread it works fine with upload. I need to upload multiple files and each file has one entry in autocdrfiles and one entry in userfiles tables. I thought that was what was meant with one-to-one.
    So it seems I do need an MJoin? As test #1 above indicates the upload works and but I get only one entry in autocdrfiles table no matter how many files I try to upload and that entry has no id in its userfileid field. Can you help? Thanks as ever.

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Okay, yup, let's both get on the same page before we mess around with much more code!

    You are using:

    editor = new Editor(db, "AutoCDRFiles")
    

    which means the Editor is editing the AutoCDRFiles table. You note above that this table has 1:1 with the UserFiles table.

    I'm not clear on the multiple files aspect. Every entry in AutoCDRFiles will be represented by a single row in a DataTable. If you wanted multiple grouped together you'd need a grouping row in a separate database table.

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    "The Editor is editing the AutoCDRFiles table"

    Yes, that is correct.

    "I'm not clear on the multiple files aspect"

    The editor is jus taking many/multiple upload files

    "Every entry in AutoCDRFiles will be represented by a single row in a DataTable."

    Yes, that is correct.

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    I'm not quite understanding that - sorry if I'm being denser than normal here!

    If you have each row in the AutoCDRFiles table shown as a row in the DataTable and you have a 1:1 relationship for the files, then where would the multiple files upload come into play?

    Are you looking to have a create form that can accept multiple files for upload ins a single go and that would create multiple rows in the AutoCDRFiles table? If so, I'm afraid that's not a feature that Editor supports at the moment. One "Create" view === one row in the database is how it works.

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    Are you looking to have a create form that can accept multiple files for upload ins a single go and that would create multiple rows in the AutoCDRFiles table?

    Yes.

    Each uploaded file would have a row in AutoCDRFiles.

    Is that likely to be supported? If so do you have a timescale?

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    I use a table (userfiles) to keep basic and common parameters to do with the users' uploaded files such as the name, path, size of files. To have to use your model means I will have to move all the disperate fields that I currently use in all my tables that deal with uploaded files to that table. That does not make a lot of sense.

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Ah okay - that's why I wasn't getting it before. I'm afraid that this is not a feature that is on our roadmap since its the first time its come up!

    It is possible to use create() to create multiple new rows at once, but that wouldn't work for multiple images since that is embedded into the form - i.e. if we went that way, each new row would all have the same image values!

    To have to use your model means I will have to move all the disperate fields that I currently use in all my tables that deal with uploaded files to that table. That does not make a lot of sense.

    I agree - it doesn't. I'm not sure why you would need to move the various fields?

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3
    edited October 2019

    "I agree - it doesn't. I'm not sure why you would need to move the various fields?"

    Because one single row field in a table like autocdrfiles cannot hold data for each individual uploaded file.

  • allanallan Posts: 51,736Questions: 1Answers: 7,827 Site admin

    Right - but isn't that the point of having a central table for storing file meta information? Any other table that needs to reference a file can just use a left join link to the central files table, which then has the general file information such as extension, size, etc.

    That way any information that is specific to the host table is held in the host table while generic file information is held in the files table.

    That is the pattern that this example uses.

    Allan

  • dynasoftdynasoft Posts: 309Questions: 50Answers: 3

    AutoCDRFile does not hold file meta information. The files are analysed by the programme and hold other fields specific to those tasks (ie different from meta info about the file), such as the scan date, if the scan was successful, the scan type,...).

    "Any other table that needs to reference a file can just use a left join link to the central files table"

    This would presuppose, again, that I would have to move all the fields about the scan to that files table when that files table should only hold meta info about the file and nothing else.

Sign In or Register to comment.