Storing files via IPFS privatley

Hey,

I want to add a feature to my app to let a user to upload an image file, but I want the file to be private.
I tried IPFS and the file system as mentioned in the documentation, but both of them generate a public URL to download the file. The URL is hashed and I think it would be really hard to guess, but it is still public.

Is there any way to upload a file without generating this link? or have some sort of permission that will allow only my Moralis server/client to download it?

Thanks!

I would think that you could encrypt the data that gets uploaded to IPFS and decrypt it before it is returned to the user.

I was thinking about this, but I couldn’t manage to encrypt the file using RSA and upload it.
I didn’t find a way to just encrypt the file object, so I tried converting it to base64 and then encrypting, getting an error saying the string is too long to be encrypted.

any ideas?

Thanks!

I would think that you can encrypt any size, what was the size when it got that error?

did you try with smaller sizes?

less than 1kb, I took a 400 bytes text file, converted it to base64, and tried to encrypt it with a 4096 public key.
from what I read you can’t encrypt a string larger than the public key, so I will have to use some combination of symmetric and asymmetric encryptions.

Is there any other way to do so? or I can just upload them as blob directly to the mongo.

Thanks!

There has to be a way to encrypt them. If you upload the in mongo you may also need to encrypt them.

Found a way using the combination of the methods, couldn’t find anything simpler.
Will probably need to send the entire file to the server and then upload it encrypted because it is easier in node.

For now, this is a big down side using moralis server IMO :expressionless:

What is the big downside?