File Storage On IC

Hi, community,

I have skimmed through the documentation for an in-depth reference of storage on IC, couldn’t find it.

  • Can anybody share some insight on how it is possible to store files(i.e. .png, .pdf, .mp4, .mkv) on IC?
  • What is most optimal solution to store large files( >10MB ) on IC?
5 Likes
  • Can anybody share some insight on how it is possible to store files(i.e. .png, .pdf, .mp4, .mkv) on IC?

You just store them as bytes at any location in the canister you want.

  • What is most optimal solution to store large files( >10MB ) on IC?

Split them in chunks and save each chunk separately. Once you need a complete file - download chunks and merge them back on a user side.

4 Likes

Thank you @senior.joinu for your response. I am new to IC, reference links to docs or related example would be much appreciated.

1 Like

@kpeacock I don’t mean to spam you. Just wanted to point out that there’s at least one other person who would probably appreciate a video tutorial on file management.

3 Likes

@Jesse I would love to enjoy your sense of humor if it could provide any value at all.

I wasn’t being humorous. I requested that Kyle make a video tutorial on how to do exactly what you’re asking in this post. I referenced this post and one other post as evidence that there are multiple people who would appreciate the tutorial. As a result, Kyle said that he’d make the tutorial when he gets the time.

so I’d say my comment actually did add some value if it results in a video tutorial explaining the very thing you’re requesting help with.

4 Likes

Hopefully this code helps:

This is how CanCan chunks video files. Basically, take a big byte array (i.e. Array<number>) and split it up!

Here’s another one:

The tricky part IMO is getting this byte array from a file. You might need to use blobs or ArrayBuffers or something like that… it’s in this code.

7 Likes

@Jesse thank you for your help and apology for misreading intent.

1 Like

Thank you @jzxchiang , it’s very helpful indeed!

2 Likes

Hi,

To add a point to this thread, in addition to the difficulty of implementing a large volume storage system using one or more canisters, there is the question of the price per GB.
The solution that consists of cutting up packets of bytes, with the goal of scalability, technical performance and efficiency, does not seem to me to be ideal with this technology today. But since dfinity has many advantages, I asked myself how to solve this problem.
I will combine my dApp with dfinity and ipfs, ipfs-cluster for large media, I store on dfinity an object which is a pointer to the ipfs CID so I keep the distributed attribute of the solution and I benefit from the existing interfaces for the management of these contents.
I can use either my ipfs infrastructure or existing online solutions.

For public media it seems to me an interesting alternative in terms of complexity and cost. I am now thinking about how to use a similar concept for media that need to be protected.

You can see on the forum a lot of threads by searching “bigMap”

Regards

3 Likes

Hi guys, I just want to know if anyone knows of a function built into Motoko that allows the user to upload a file(assume all the files uploaded would be the same format) to the canister and store it there? The files won’t be large.

1 Like

You can use
https://mops.one/assets
or
https://mops.one/motoko-certified-assets
or
https://mops.one/server

for asset storage. I know assets and server are compatible with the npm package @dfinity/assets and the icx-asset cli tool from GitHub - dfinity/sdk: IC SDK: a Software Development Kit for creating and managing canister smart contracts on the ICP blockchain.

4 Likes

So i guess . maybe there haven’t a blockchain version of dropbox on the IC ecosystem yet?