file attachements not showing in shared notebook

Hey,

I’ve created a shared but unlisted notebook which has over 100 small image files. I’m able to see and use them when logged in but not when I share the notebook (no file attachments are shown). What’s the issue?

perhaps I’m over some limit, as I can share a notebook with a single FA.

I don’t think this is a problem with a limit…

When I look at the notebook, I see that the notebook code dynamically loads the file attachments (except for that last cell, which I see you added after making the notebook public (unlisted). This is the issue… when you make a notebook public, we don’t make all file attachments publicly accessible, because that might make attachments public that you did not necessarily plan to make public. Instead, we do static analysis of the code in the notebook to determine which files attachments to make public. In your case, if didn’t find any files referenced, so they weren’t made public.

The ‘fix’ would be to simply upload those again while the notebook is public.

2 Likes

Unpublish your notebook (“no access”) then publish it again and the attachments should become accessible.

1 Like

… I hadn’t noticed that you reference your attachments dynamically which is not (well) supported in Observable.

I recommend the following steps:

  1. Go to How To List FileAttachments Dynamically / Fabian Iwand | Observable and follow the steps under “Private notebooks” to obtain a list of your attachments.
  2. Reference them in a cell as explained in the files = { ... } example.
  3. Unpublish your notebook.
  4. Publish your notebook again.
2 Likes

To add to what @mootari said, you need to list out your files statically like the code below. Observable requires you to reference files statically so that we know which files are in use and can make them public when the notebook is made public. There’s a similar requirement for secrets and databases, and that’s why FileAttachment throws an error when you try to pass in a dynamic string.

Here’s a live example:

(Eventually we’d like to make some changes to how file attachments work in Observable that would eliminate this requirement, but that change likely won’t be soon.)

files = [
  FileAttachment("1500.jpg"),
  FileAttachment("1501.jpg"),
  FileAttachment("1502.jpg"),
  FileAttachment("1503.jpg"),
  FileAttachment("1504.jpg"),
  FileAttachment("1505.jpg"),
  FileAttachment("1506.jpg"),
  FileAttachment("1507.jpg"),
  FileAttachment("1508.jpg"),
  FileAttachment("1509.jpg"),
  FileAttachment("1510.jpg"),
  FileAttachment("1511.jpg"),
  FileAttachment("1512.jpg"),
  FileAttachment("1513.jpg"),
  FileAttachment("1514.jpg"),
  FileAttachment("1515.jpg"),
  FileAttachment("1516.jpg"),
  FileAttachment("1517.jpg"),
  FileAttachment("1518.jpg"),
  FileAttachment("1519.jpg"),
  FileAttachment("1520.jpg"),
  FileAttachment("1521.jpg"),
  FileAttachment("1522.jpg"),
  FileAttachment("1523.jpg"),
  FileAttachment("1524.jpg"),
  FileAttachment("1525.jpg"),
  FileAttachment("1526.jpg"),
  FileAttachment("1527.jpg"),
  FileAttachment("1528.jpg"),
  FileAttachment("1529.jpg"),
  FileAttachment("1530.jpg"),
  FileAttachment("1531.jpg"),
  FileAttachment("1532.jpg"),
  FileAttachment("1533.jpg"),
  FileAttachment("1534.jpg"),
  FileAttachment("1535.jpg"),
  FileAttachment("1536.jpg"),
  FileAttachment("1537.jpg"),
  FileAttachment("1538.jpg"),
  FileAttachment("1539.jpg"),
  FileAttachment("1540.jpg"),
  FileAttachment("1541.jpg"),
  FileAttachment("1542.jpg"),
  FileAttachment("1543.jpg"),
  FileAttachment("1544.jpg"),
  FileAttachment("1545.jpg"),
  FileAttachment("1546.jpg"),
  FileAttachment("1547.jpg"),
  FileAttachment("1548.jpg"),
  FileAttachment("1549.jpg"),
  FileAttachment("1550.jpg"),
  FileAttachment("1551.jpg"),
  FileAttachment("1552.jpg"),
  FileAttachment("1553.jpg"),
  FileAttachment("1554.jpg"),
  FileAttachment("1555.jpg"),
  FileAttachment("1556.jpg"),
  FileAttachment("1557.jpg"),
  FileAttachment("1558.jpg"),
  FileAttachment("1559.jpg"),
  FileAttachment("1560.jpg"),
  FileAttachment("1561.jpg"),
  FileAttachment("1562.jpg"),
  FileAttachment("1563.jpg"),
  FileAttachment("1564.jpg"),
  FileAttachment("1565.jpg"),
  FileAttachment("1566.jpg"),
  FileAttachment("1567.jpg"),
  FileAttachment("1568.jpg"),
  FileAttachment("1569.jpg"),
  FileAttachment("1570.jpg"),
  FileAttachment("1571.jpg"),
  FileAttachment("1572.jpg"),
  FileAttachment("1573.jpg"),
  FileAttachment("1574.jpg"),
  FileAttachment("1575.jpg"),
  FileAttachment("1576.jpg"),
  FileAttachment("1577.jpg"),
  FileAttachment("1578.jpg"),
  FileAttachment("1579.jpg"),
  FileAttachment("1580.jpg"),
  FileAttachment("1581.jpg"),
  FileAttachment("1582.jpg"),
  FileAttachment("1583.jpg"),
  FileAttachment("1584.jpg"),
  FileAttachment("1585.jpg"),
  FileAttachment("1586.jpg"),
  FileAttachment("1587.jpg"),
  FileAttachment("1588.jpg"),
  FileAttachment("1589.jpg"),
  FileAttachment("1590.jpg"),
  FileAttachment("1591.jpg"),
  FileAttachment("1592.jpg"),
  FileAttachment("1593.jpg"),
  FileAttachment("1594.jpg"),
  FileAttachment("1595.jpg"),
  FileAttachment("1596.jpg"),
  FileAttachment("1597.jpg"),
  FileAttachment("1598.jpg"),
  FileAttachment("1599.jpg")
]
3 Likes

Thanks for the example. I’ve implemented as you suggested but I’m getting a bunch of Error: Unable to load file: 1539.jpg errors when I share the notebook (unlisted). Any ideas?

Looks like you figured it out :slight_smile: You are missing the @1 for some of those files.

Well some of the files were showing errors, but only after I tried to 'Insert into notebook", otherwise they looked okay in the FA panel. However, if I opened the notebook in incognito and opened the FA panel, I’d see a few files showing errors.

Before I tried sharing the notebook all of the files were fine, so I’m not sure what is happening when I share, but that seems to be when the error occur.

Here’s another one that works when not shared but shows errors with the file attachments when shared https://observablehq.com/d/571c91d924d6c7a5
It’s working now (unshared) but this is what I see when shared.

Very strange. Could you share it again so that we can take a look at it?

1 Like

Yes, just shared it, thanks!

Thanks. Looking into it.

Hello! I’m Cam at Observable and I’m trying to dig into this issue. Just to confirm, after listing the files as suggested by Fabian and Mike, did you make the notebook private and then share it again?

Yes, I tried a few times with this notebook https://observablehq.com/d/571c91d924d6c7a5

Thank you! I’ll follow up when I have some more information.

1 Like

It seems that your notebook attachments are now all showing up. Is that what you’re seeing as well?

As an update, it appears that some changes we made recently have added some latency to publishing/unpublishing and this resulted in some timeouts which allowed your notebook to get into an odd half published state (as far as attachments go). I’m working on a fix so that this won’t happen again. Sorry for the disruption!

2 Likes