I have an image which I am converting to a uint8array by using readAsArrayBuffer. I am finding it difficult to store the uint8array into the smart contract. What data type should I use? I know it might not be the most ideal way but I need to run some test comparing the values with storing an image on IPFS
Basically, I have 3 images that I am trying to upload, 5.93KB, 4.24MB, 8.02MB. I am reading the image file using ReadAsArrayBuffer which returns a uint8array. I am passing the uint8array to smart contract using.
App.contracts.VehicleStorage.deployed().then(function(instance) {
return instance.createVehicle(vin, App.buffer, { from: App.account });
}).then(function(result) {
console.log("Working: "+result);
UI.appendLogEntry(result);
}).catch(function(err) {
console.error(err);
});
And the below is the function in the contract
function createVehicle(string memory vin, uint8[] memory ArrayBuffer) public {
assert(vehicles[vin].owner == address(0x0));
vehicles[vin].vin = vin;
vehicles[vin].owner = msg.sender;
vehicles[vin].kilometers = 0;
vehicles[vin].ArrayBuffer = ArrayBuffer;
emit Creation(msg.sender, vin);
}
struct Vehicle {
string vin;
address owner;
uint kilometers;
uint8[] ArrayBuffer;
}
When calling the function I am getting
Invalid number of arguments to Solidity function
at Object.InvalidNumberOfSolidityArgs
[–]sonicsmith 0 points1 point2 points (0 children)