question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue while uploading image

See original GitHub issue
I20200123-18:57:34.751(5.5)? Exception while invoking method 'collections.images.insert' TypeError: Cannot read property 'insert' of undefined
I20200123-18:57:34.753(5.5)?     at MethodInvocation.collections.images.insert (imports/api/collections/methods.js:20:31)
I20200123-18:57:34.753(5.5)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1771:12)
I20200123-18:57:34.753(5.5)?     at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20200123-18:57:34.754(5.5)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
I20200123-18:57:34.754(5.5)?     at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20200123-18:57:34.754(5.5)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
I20200123-18:57:34.754(5.5)?     at Promise (packages/ddp-server/livedata_server.js:715:46)
I20200123-18:57:34.755(5.5)?     at new Promise (<anonymous>)
I20200123-18:57:34.755(5.5)?     at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20200123-18:57:34.755(5.5)?     at packages/ddp-server/livedata_server.js:559:43

Collection constructor server Code :

import { FilesCollection } from 'meteor/ostrio:files';

const Collections_Images = new FilesCollection({
	collectionName: 'collections_images',
	storagePath: 'uploads/Collections-Images',
	allowClientCode: false,
	onBeforeUpload(file) {
		// Allow upload files under 10MB, and only in png/jpg/jpeg formats
		if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
			return true;
		}
		return 'Please upload image, with size equal or less than 10MB';
	}
});

export default Collections_Images;

Created method Code :

import { Meteor } from 'meteor/meteor';
import { Collections_Images } from './collections_img.js';

Meteor.methods({
  'collections.images.insert'(images) {
    return Collections_Images.insert({
          file : images,
          streams: 'dynamic',
          chunkSize: 'dynamic',
        })
  },
});

Client side js code:

"change #myFileInput" : function(event){
        const images = event.currentTarget.files[0];
        Meteor.call('collections.images.insert',images, (error) => {
            if(error){
                alert("collection image insert : "+error.message);
            }
            else{
                images=null;
            }
        });
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kaushalbrahmbhatt38commented, Jan 24, 2020

But now my problem is solved. As .insert(update) method is on client side. And Correct importing of Collection_img.js is : import Collections_Images from './collections_img.js'; because i’m exporting default from ‘./collections_img.js’

Again Thanks @jankapunkt and @dr-dimitru for your help.

0reactions
dr-dimitrucommented, Jan 24, 2020

@kaushalbrahmbhatt38 I’m glad it’s solved. Feel free to reopen it in case if the issue is still persists on your end.

Please support this project with:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Message: There are errors below. Hover over each for ...
We're sorry you're having trouble uploading an image! Sometimes these messages show up when uploading an image from your computer.
Read more >
5 Easy Steps to Fix an Http Error When Uploading Images to ...
5 Steps to Fix an HTTP Error When Uploading Images to WordPress · Step 1: Find Out If the HTTP Error is Temporary...
Read more >
How to Fix Image Upload Issue in WordPress (Step by Step)
The image upload issue in WordPress is typically caused by incorrect file permissions. Your WordPress files are stored on your web hosting ...
Read more >
5 Ways to Fix Common WordPress Image Upload Issues
1. Rename, Resize, and Re-Upload the Image · 2. Increase the Memory Limit · 3. Deactivate Your Plugins · 4. Clear the Cache...
Read more >
How to Quickly Fix Image Upload Issues in WordPress
Another sign of this issue is that your images may not appear in the media library. You can then change the file permissions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found