Nodejs Angular දන්න අයගෙන් ලොකු උදව්වක්

Rowdy Baby

Well-known member
  • Dec 22, 2018
    3,229
    4,470
    113
    Colombo
    මචන්ලා මට මෙහෙම එකක් හදා ගන්න ඔනි.
    උදා ලමයෙක් ටයිටල් එකට OL certificate කියලා දීලා file chooser එකෙන් අදාල ෆයිල් එක තෝරනවා .ඊට පස්සේ AL certificate කියලා දීලා අදාල ෆයිල් එක තෝරනවා .ඊට පස්සේ nodejs backend eke අදාල යුසර්ගේ නමට හැදුන ෆොල්ඩර් එකේ මේ ෆයිල් දෙක සේව් වෙන අතර මොන්ගොඩීබි එකේ ෆයිල් නේම් එකත් එක්ක ෆයිල් පාත් එක සේව් වෙන්න හදා ගන්නේ කොහොමද ලොකු උදව්වක් මචන්ලා බම්ප් එකක් හරි දාන් යන්න.
    elakiri.png
     

    Anonymous_Abstract

    Well-known member
  • Aug 7, 2018
    6,036
    4,570
    113
    Messier 87
    Vps eka file store karana path ekama string vidiyata aran db vala save karapan. Id,name,path column 3i file table eka. User to file, 1 to M

    Sorry mongod db relationship na na. File document ekata user id danna wei. No Sql experience thiyena ekek reply karai
     
    Last edited:

    Dasunx

    Active member
  • Jul 7, 2020
    200
    234
    43
    dasunx.com
    You can send those files as multipart/form-data from front end to backend and, you can use something like Multer to handle it in the backend. With Multer you can specify a file path (new folder for a user). Then you can get the file path and save it in MongoDB.

    you can save it directly in the user collection or you can manage a different collection for file paths, that will contain these fields.
    JSON:
    {
        userId : "userId from user collection",
        ol_file_path: "file path",
        al_file_path: "file path"
    }

    if file titles are dynamic
    JSON:
    {
        userId: "user id from user collection",
        files : [
            {
                title: "title given by user",
                file_path: "file path"
            },
            {
                title: "second title given by user",
                file_path: "second file path"
            }
        ]
    }

    This is my suggestion.
    Instead of uploading files to your server, you can use a 3rd party service (like AWS S3). This will help you in the long run.