hicetnunc icon indicating copy to clipboard operation
hicetnunc copied to clipboard

Interactive OBJKTs with subfolders cannot be previewed

Open keaukraine opened this issue 3 years ago • 14 comments

It is stated in docs that "Subfolders are ok." However when I upload and preview interactive OBJKT with subfolders, I get 404 errors for resources in subfolders.

Steps to reproduce Steps to reproduce the behavior:

  1. Upload zip with resources in subfolders.
  2. Preview it.

Expected behavior All resources are accessible.

keaukraine avatar May 08 '21 14:05 keaukraine

It is stated in docs that "Subfolders are ok."

Can you link me to that information? I'm pretty sure that's incorrect unless something changed and I'm not aware..

andrevenancio avatar May 10 '21 14:05 andrevenancio

Link to wiki page where it is stated that "Subfolders are OK": https://github.com/hicetnunc2000/hicetnunc/wiki/Interactive-OBJKTs#folder-structure

keaukraine avatar May 10 '21 18:05 keaukraine

And yes I managed to make my interactive HTML+JS OBJKT to work after flattening it to root folder (this required refactoring of code). Placing 20+ resources in root which looks a bit ugly TBH.

keaukraine avatar May 10 '21 18:05 keaukraine

@keaukraine subfolders should indeed work. Can you provide a sample zip file so I can test? Thanks

pichiste avatar May 12 '21 05:05 pichiste

@keaukraine Would you mind testing with this zip? nested-folders.zip

Perhaps you are using absolute paths in your code? I realized it wasn't clear in the docs that you need to use relative paths – have updated the guide.

Screen Shot 2021-05-12 at 7 37 20 AM

pichiste avatar May 12 '21 05:05 pichiste

I was trying to mint an interactive OBJKT with subfolders, and indeed, I had trouble getting it to work. Then when I flattened it as @keaukraine suggests, it started to work! My file paths were all relative; the only difference is that I moved everything outside the nested folder.

damondpham avatar Jun 01 '21 04:06 damondpham

But @pichiste your test zip works for me too, so I'm not sure what the problem is.

damondpham avatar Jun 01 '21 04:06 damondpham

Hey @damondpham, could you share a sample zip file that exhibits the error with the subfolders? I'm unable to reproduce the problem so it would be very helpful. Thanks

pichiste avatar Jun 01 '21 07:06 pichiste

Sure, here is an example. The html file should show a white square against a blue background, but the white square is absent in the H=N preview. HEN_bug.zip

damondpham avatar Jun 01 '21 08:06 damondpham

If I replace the div having the image background with a regular tag that also doesn't work. Here the white square becomes a 404 icon for me. HEN_bug2.zip

damondpham avatar Jun 01 '21 08:06 damondpham

@damondpham Thanks for posting the test file – strangely, if I unzip, then re-zip your test file, it works for me (I'm on mac). Can you try with this one?

HEN_bug_rezipped.zip

Are you on Windows by chance? There was a case before where a similar issue occurred, where a zip created on Windows didn't work, but did work if unzipped/re-zipped on a mac.

pichiste avatar Jun 01 '21 08:06 pichiste

Your re-zipped file works for me. Yes, I'm on Windows! So that seems to be the issue.

damondpham avatar Jun 01 '21 08:06 damondpham

Ok, good to know. I will need look further into this when I can get access to a windows machine to test on. Will report back here with findings. Thanks for helping track this down!

pichiste avatar Jun 01 '21 08:06 pichiste

I encountered the same issue on MacOS and discovered that it was caused by how I was creating the zip archive.

My directory structure is:

➜  cd project
➜  tree .        
.
├── dist
│   └── index.js
├── index.css
└── index.html

And index.html references dist/index.js through the following script tag <script type="module" src="dist/index.js"></script>.

From within the project directory, if I create the zip archive with zip -r project.zip ., I get the 404 error.

From within the project directory, if I create the zip archive with MacOS Archive Utility via Finder, or with the following command ditto -c -k --sequesterRsrc --keepParent . project.zip, everything works as expected.

jshrake avatar Sep 19 '21 17:09 jshrake