How do you support static artifacts like images and videos?

So if I want to build a new awesome service on Dfinity, it’s going to need to look good. So I’ll want to add js, css, images and videos to help. Got the js and css. How do I add other static assets like images, videos, .pdf’s? It seems like they need to be hosted elsewhere? Doesn’t that seem contrary to the goal of a service that promises to offer the next gen internet. I could host at AWS or anywhere really, but I feel like I am missing something super obvious (likely), or Dfinity is missing something super obvious (less likely?).

1 Like

Not a perfect example, but you can load in assets from your frontend canister like so

Similarly, you could create a little bucket canister in Motoko and use that to serve yourself Blobs or [Nat8]s

Thanks! Yes saw this for pulling in simple html fragments. Lot of work for html but I could see this working. Not sure how this would work for images or an image directory however, e.g:

<img src='img/logo.png'></img>

Hmmm, you should be able to attach the result of URL::createObjectURL to img.src. However, you’re right this doesn’t solve the larger problem of being able to quickly resolve multiple files. Doing this dance each time would be kinda lame.

2 Likes