Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get file from post method? #289

Open
abhirajevolvier opened this issue Feb 6, 2018 · 0 comments
Open

How to get file from post method? #289

abhirajevolvier opened this issue Feb 6, 2018 · 0 comments

Comments

@abhirajevolvier
Copy link

Here I'm not able to get the file in server side.
Please help

Server side:


const testImages = new FilesCollection({
  storagePath: process.env.PWD + "/uploads/testImages",
  collectionName: "testImages"
});

Api.addRoute('testImages', {authRequired: false}, {
        post: function () {
            var uploadedFile = new fs.File(this.request.files.file.path);
            var insertedFile =  testImages.insert(uploadedFile, function (err, fileObj) {
                if (err) {
                    console.log(err);
                } else {
                    console.log(fileObj.size()+" "+fileObj.name()+" "+fileObj.extension());
                }
            });
            return {
                status: "success",
                data: insertedFile._id
            }
        }
    }
);

Client Side (Postman plugin)
screen shot 2018-02-06 at 6 39 51 pm

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant