Usually, you get that error when the wrong type of data is sent, like a variable instead of a value.
Can you add some logging? Like logging the size of the sent data?
Usually, you get that error when the wrong type of data is sent, like a variable instead of a value.
Can you add some logging? Like logging the size of the sent data?
I have a limit of 8mb before the upload so I know the size isnāt the problem.
Either ways I printed out the actual size.
5799702 ~= 5MB
ok, and that data makes it to the cloud function, an the cloud function gives that particular error?
Exacly that yes,
The line that fails is the one that tries to upload the file to the IPFS
const fileToSave = await Moralis.Cloud.toIpfs({
sourceType: "base64Binary",
source: imageBase64,
});
ok, got it, Iāll have to test it today/tomorrow to see how it repicates
that link (https://i.ibb.co/6v4BPrW/1.png
) points to a ~4MB file
Oh mb, 5799702 is the number of chars in the string, I usually calculate the size by multiplying by 3/4. ~= 4349776 bytes ~= 4.1483 Megabytes
Thatās the correct image and the size on the client is exactly the same when it reaches the server
I get a smaller size for the original file and also for the base64 encoding, maybe you also have the file name there?
If youāre getting 4349760 then thatās the true size, 4349776 is just an estimation
I was able to reproduce the error
Awesome, now the hard part comes, why is it happening
Hey again,
Have you got any news about this issue?
I donāt know yet. It looks to be related to a library that checks that base64 buffer. You could try to use upload folder functionality from web3api as an alternative.
Hey @cryptokid!
Just wanted to know if we should start using the āupload folderā functionality everywhere instead of the āoriginalā way or if itās going to get fixed at some point!
You can try uploadFolder functionality, I donāt know when it will be fixed.
Thanks for the reply,
Is uploadFolder compatible with other ipfs gateways (beyond moralis ones)?
Like āhttps://infura-ipfs.io/ipfs/ā for instance
yes, it is compatible with the other ipfs gateways.
Sorry for so many questions but it looks like uploadFolder canāt be used in cloud functions. Is that right?
it should work without problems, it is only a web3api call, you can also call it directly has REST api
So web3api call works! Thanks for the help.
I still personally prefer using normal hash without the āfolder/filenameā at the end. This way I could find duplicates easily, because same file generates same ipfs hash.
Correct me if Iām wrong but this isnāt possible with web3api (I suppose) because it uploads a folder instead of a single file.
Meanwhile I got some more examples that break āMoralis.Cloud.toIpfsā that my users found while trying to upload images to the dapp.
https://ufile.io/dlh55d4h (4 images total, for now, from +500 images posted)
you can use same folder and file path for all the uploaded files, like /a/b.c