PennController for IBEX › Forums › Support › .zip file problems
- This topic has 46 replies, 7 voices, and was last updated 3 years, 5 months ago by samsanto.
-
AuthorPosts
-
April 16, 2019 at 11:31 pm #3191Katya MorgunovaParticipant
Hello,
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?Best regards,
KatyaApril 17, 2019 at 12:15 am #3192JeremyKeymasterHi Katya,
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.
PennController tries to download the ZIP file in the background at the beginning of the experiment. As this is done automatically via javascript, it is different from a manual download of the ZIP file (hence the need to use the .htaccess method).
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.You can open your browser’s javascript console and refresh the page to look for any CORS related error/warning message: if you see any, it means that something is not right with the .htaccess configuration.
Let me know if the problem persists.
Best,
JeremyApril 22, 2019 at 5:48 pm #3308Katya MorgunovaParticipantDear Jeremy,
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:
https://morgunovakatya.ru/experiment/image.pngDo you know what else I might be doing wrong?
Best,
KatyaApril 23, 2019 at 10:08 am #3309JeremyKeymasterHi Katya,
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.
Best,
JeremyJune 5, 2019 at 12:46 am #3699grusha.prasadParticipantHi Jeremy,
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?
Thank you,
Grusha.June 5, 2019 at 12:25 pm #3700JeremyKeymasterHi Grusha,
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:
– https://aws.amazon.com/blogs/aws/amazon-s3-cross-origin-resource-sharing/
– https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html#how-do-i-enable-corsYou 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
Jeremy
June 5, 2019 at 5:07 pm #3703grusha.prasadParticipantHi Jeremy,
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?
Thanks again!
Grusha.
June 5, 2019 at 5:25 pm #3704JeremyKeymasterHi Grusha,
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
Jeremy
June 5, 2019 at 5:36 pm #3705grusha.prasadParticipantThank 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 #3706JeremyKeymasterI 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
Jeremy
June 5, 2019 at 9:45 pm #3707grusha.prasadParticipantI 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 #3708JeremyKeymasterThanks. MP3 does make it work: https://expt.pcibex.net/ibexexps/example/grusha/experiment.html
And you can see the content ofmain.js
here.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
Jeremy
- This reply was modified 5 years, 4 months ago by Jeremy.
June 6, 2019 at 1:06 am #3711grusha.prasadParticipantThanks 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 #3785JeremyKeymasterHi 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.
Jeremy
March 29, 2020 at 3:06 pm #4922EliseParticipantHi Jeremy,
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?
Best,
Elise -
AuthorPosts
- You must be logged in to reply to this topic.