.zip file problems

PennController for IBEX Forums Support .zip file problems

This topic contains 13 replies, has 3 voices, and was last updated by Jeremy Jeremy 6 days, 9 hours ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #3191
    Avatar
    Katya Morgunova
    Participant

    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,
    Katya

    #3192
    Jeremy
    Jeremy
    Keymaster

    Hi Katya,

    Specific requirements for the .zip file are described here:

    Zipped Resources

    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,
    Jeremy

    #3308
    Avatar
    Katya Morgunova
    Participant

    Dear 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.png

    Do you know what else I might be doing wrong?

    Best,
    Katya

    #3309
    Jeremy
    Jeremy
    Keymaster

    Hi 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,
    Jeremy

    #3699
    Avatar
    grusha.prasad
    Participant

    Hi 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.

    #3700
    Jeremy
    Jeremy
    Keymaster

    Hi 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-cors

    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

    Jeremy

    #3703
    Avatar
    grusha.prasad
    Participant

    Hi 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.

    #3704
    Jeremy
    Jeremy
    Keymaster

    Hi 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

    #3705
    Avatar
    grusha.prasad
    Participant

    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 🙁

    #3706
    Jeremy
    Jeremy
    Keymaster

    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

    Jeremy

    #3707
    Avatar
    grusha.prasad
    Participant

    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.

    #3708
    Jeremy
    Jeremy
    Keymaster

    Thanks. MP3 does make it work: https://expt.pcibex.net/ibexexps/example/grusha/experiment.html
    And you can see the content of main.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 1 week, 4 days ago by Jeremy Jeremy.
    #3711
    Avatar
    grusha.prasad
    Participant

    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)

    #3785
    Jeremy
    Jeremy
    Keymaster

    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.

    Jeremy

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.