Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lepozepo s3 Cannot read property 'upload' of undefined #165

@harvinder34

Description

@harvinder34

I am creating API to upload a image and using busboy as middle ware to get uploaded image.
And now i need to upload image on aws. To upload image on aws i am using lepozepo:s3 package but it returns error http://prntscr.com/olfi5j . This is my code i write in app\server\server.js file

Router.route('/api/uploadimg/', { where: 'server' })
.post(function () {

let response;
var files = this.request.filenames;
console.log(this.request.filenames);

import {S3} from "meteor/lepozepo:s3";

S3.upload({ 
    files:files,
    path:"avatars"
  },function(e,r){
    if (!e) {
      var $set={};
      $set[templ.data.picType]=r.secure_url;
      Meteor.users.update({
        _id: userId
      }, {
        $set: $set
      }, function(err) {
        if (!err) {
          console.log( "Image uploaded");
        } else {
          console.log("Error updating image");
        }
      });
    } else {
      console.log( "Error updating image");
    }
});

response = {
        "errorCode": false,
        "statusMessage": "Picture uploaded successfully",
		data: files
      }
this.response.setHeader('Content-Type', 'multipart/form-data');
this.response.setHeader('Access-Control-Allow-Headers', '*');
this.response.end(JSON.stringify(response));

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions