Cannot read property 'buffer' of null

Hi, I am getting below error in my safe browser when I tried to execute “Upload” operation.
Below is the error. I am trying to use safeMutable insert.

Code

  	function uploadVideo() {
  		//basically id becomes a container and to be defined as below.
  		var container = 'apps/safetube-vijay';
  		
  		var _file = document.getElementById("vfile");
  		var _reader = new FileReader();
  		
  		var _content = null;
  		
  		_reader.readAsArrayBuffer(new Blob([_file.files[0]]));
  		_reader.onload = function(_event) {
  			var arrayBuffer = _reader.result;
  			_content = new Uint8Array(arrayBuffer);
  			return _content;
  		};
  		
  		window.safeApp.getContainer(auth, container)
  			.then((mdHandle) => {
  				window.safeMutableData.newMutation(auth)
  					.then((mutationHandle) => 
  						window.safeMutableDataMutation.insert(mutationHandle, _file.files[0].name, _content).then(() =>
  							console.log('New mutation entry has been committed to the network')));
  			},
  			(err) => {
  				console.error(err);
  			});
  	}

Please check the error below. Please help me to find what is causing the error. This error happens to be new. I was able to upload before with the same code before.

Uncaught (in promise) Error: Cannot read property ‘buffer’ of null
** at Array.slice.call.forEach.item (C:\Program Files\MaidSafe\safe-browser\resources\app\node_modules@maidsafe\safe-node-app\src\native_mutable.js:121:55)**
** at Array.forEach (native)**
** at Function.strToBuffer (C:\Program Files\MaidSafe\safe-browser\resources\app\node_modules@maidsafe\safe-node-app\src\native_mutable.js:120:46)**
** at Promise (C:\Program Files\MaidSafe\safe-browser\resources\app\node_modules@maidsafe\safe-node-app\src\native_base.js:97:32)**
** at Promise ()**
** at Object.mdata_entry_actions_insert (C:\Program Files\MaidSafe\safe-browser\resources\app\node_modules@maidsafe\safe-node-app\src\native_base.js:92:16)**
** at Object.insert (C:\Program Files\MaidSafe\safe-browser\resources\app\node_modules@maidsafe\safe-node-app\src\api\mutable.js:174:16)**
** at C:\Program Files\MaidSafe\safe-browser\resources\app\node_modules\beaker-plugin-safe-app\dist\api.js:2831:23**
** at **

Hey @vjbollavarapu,

Your _content is set as expected before you start trying to pass to the network (so before you run window.safeApp.getContainer(auth, container) etc)?

1 Like

Dear @joshuef,

YES, It is. Is there any problem?? I am facing this error even for the previously working app. This is why I am surprised.

What are the values of _file.files[0].name and _content, when logged?

Which version of SAFE Browser are you using?

1 Like

Hi @hunterlester

_file.files[0].name shows the name of the file I tried to upload. But the _content still remains as null. May be I got to check this why is it happening. I will check. If you can help me anything by looking at the code, you could. Thank you.

Its the screen shot of my log

I’m wondering if var arrayBuffer = _reader.result should be var arrayBuffer = _event.target.result.

You’ll need to confirm by logging _reader.result vs _event.target.result.

1 Like

As side note you’ll need to apply the mutations with safeMutableData.applyEntriesMutation after doing safeMutableDataMutation.insert.

1 Like

This topic was automatically closed after 60 days. New replies are no longer allowed.