April 16, 2019 at 11:31 pm #3191
I am having some troubles with accessing the files inside the .zip from my server.
Everything seems to be fine with the server itself, since I can download other non-zipped files from it into my experiment.
However, when I use the PennController.PreloadZip function and refer to the files from the .zip later on, the files cannot be downloaded at all (the pictures do not show and the audio files do not play).
Are there any specific requirements for the .zip file?
KatyaApril 17, 2019 at 12:15 am #3192
Specific requirements for the .zip file are described here:
You also want to make sure that your resource files are at the root of your ZIP file, rather than included in a subfolder.
And it is also different from accessing non-zipped files, as PennController downloads the zip file into the client’s cache and unzips it there to access the resource files it contains.
Let me know if the problem persists.
JeremyApril 22, 2019 at 5:48 pm #3308
Thank you for your answer. The last problem was caused by the content mismatch error (I was trying to use an http server). However, now that I have accessed another server (the https one), I am having the CORS error. The .htaccess file is in the same folder as is the .zip file, and it is exactly the same one that you give on your documentation. Here’s how it looks like:
Do you know what else I might be doing wrong?
KatyaApril 23, 2019 at 10:08 am #3309
The only explanation I can see at the moment is that, somehow, your .htaccess file does not do its job. Did you make sure that its filename is exactly .htaccess? For example, text editors sometimes automatically add a .txt extension when saving the file, and the extension might be invisible on your computer depending on your configuration.
JeremyJune 5, 2019 at 12:46 am #3699
It seems like my .htaccess is also not doing its job. When I inspect the console this is one of the errors:
Access to XMLHttpRequest at 'https://consonant-perception-exp1.s3.us-east-2.amazonaws.com/ogg_test.zip' from origin 'https://expt.pcibex.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I checked to make sure that it does not have .txt and that it is named appropriately. Here is the file on the server (and it is in the same directory as the .zip file): https://consonant-perception-exp1.s3.us-east-2.amazonaws.com/.htaccess
Do you have suggestions for how I might go about debugging this?
Grusha.June 5, 2019 at 12:25 pm #3700
I am not familiar with amazonaws, but it looks like you’re hosting your ZIP file on a cloud storage service rather than on an apache server. In that case, .htaccess files will be of no help.
It seems that you can still configure your amazonaws space to accept CORS requests:
You probably want to add these rules to your bucket:
<CORSConfiguration> <CORSRule> <AllowedOrigin>https://expt.pcibex.net</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <AllowedHeader>*</AllowedHeader> <ExposeHeader>Accept-Ranges</ExposeHeader> <ExposeHeader>Content-Range</ExposeHeader> <ExposeHeader>Content-Type</ExposeHeader> <ExposeHeader>Content-Encoding</ExposeHeader> <ExposeHeader>Content-Length</ExposeHeader> </CORSRule> </CORSConfiguration>
Let me know if this solution worked
JeremyJune 5, 2019 at 5:07 pm #3703
Thank you! That seems to resolve the CORS issue. However, now I get a 404 error.
Failed to load resource: the server responded with a status of 404 ()
The zipped folder does contain the file though. So it seems like it has access to the zipped folder but it was not able to preload the contents of the folder? Do you know what might be happening?
Grusha.June 5, 2019 at 5:25 pm #3704
I just tried preloading your ZIP file in a new experiment and it did download the archive, so you’re good on that front.
The problem comes from the structure of your archive: I downloaded it manually and opened it, and it appears to embed a folder ogg_test which itself contains the resource that you want to access (your OGG file). Try re-creating the ZIP file, but instead of archiving the folder containing your resources, directly select the file(s) that you want to include. You should see your resource files as you open your ZIP file, they shouldn’t be embedded in a folder within the archive.
Let me know if problems persist
JeremyJune 5, 2019 at 5:36 pm #3705
Thank you for the prompt response! I changed the archive structure (https://consonant-perception-exp1.s3.us-east-2.amazonaws.com/ogg_test.zip) but it still gives me the same error 🙁June 5, 2019 at 6:12 pm #3706
I suspect a problem with my code to automatically detect the type of the file. Can you try converting your audio file into a MP3 and updating the extension accordingly?
I’m sorry for the inconvenience, I’ll see if I can fix the problem for the next release of PennController
JeremyJune 5, 2019 at 9:45 pm #3707
I just uploaded the MP3 zip file (https://consonant-perception-exp1.s3.us-east-2.amazonaws.com/mp3_test.zip). Let me know if I should do anything else.
Grusha.June 5, 2019 at 11:48 pm #3708
Thanks. MP3 does make it work: https://expt.pcibex.net/ibexexps/example/grusha/experiment.html
And you can see the content of
If using MP3s instead of OGGs is an option for you, I would recommend it for now. Fixing the OGG auto-identification problem will take me some time
June 6, 2019 at 1:06 am #3711
- This reply was modified 1 year, 1 month ago by Jeremy.
Thanks for looking into this! .ogg files are slightly preferable to .mp3 for our experiment, but preloading all the files is also desirable. Just to clarify: By using CheckPreloaded() I can still make sure that all the files are pre-loaded before the experiment begins even if I am not using the zipped archive right? (i.e. I set add the host and access the individual files from the server)June 10, 2019 at 4:01 pm #3785
Hi Grusha, sorry for the late reply.
Yes, CheckPreloaded will make sure that all the files used in your trials (or only in trials with matching labels if you pass a string) are preloaded before proceeding, regardless of whether the resources live in a ZIP file or are individually fetched on a server. If CheckPreloaded fails to preload all the resources in the allotted time though, it will proceed anyway and any trial whose resources were not preloaded will try to preload them again before starting. But that shouldn’t happen if everything is configured properly.
Let me know if you have any questions.
JeremyMarch 29, 2020 at 3:06 pm #4922
is there a solution to the 404 error?
I also uploaded the zip file on amazonaws and added the CORS rules accordingly to my bucket.
This is the link to my experiment: https://expt.pcibex.net/ibexexps/Potsdam-experiments/Chai/experiment.html
And this is the link to the zip folder: https://chaipictures.s3.eu-central-1.amazonaws.com/Pictures.zip
If amazonaws is not usable for preloading a zip-file with images, could you recommend a webserver where I can rent storage and which allows cross domain request?
You must be logged in to reply to this topic.