Shailen Sukul
Shailen Sukul

Reputation: 510

Amazon S3 Static Website with Static JSON Data

I am building a really simple static website on Amazon S3 to hold my presentations. I have saved the "dynamic" data into a static JSON file on the same site and use Knockout to bind to the views.

This is working well on my local machine after adding a web.config file with the following config to allow the mime types:

     <system.webServer>
         <handlers>
           <add name="static-json" path="*.json" verb="*" modules="StaticFileModule"          resourceType="File" />
         </handlers>
         <staticContent>
           <mimeMap fileExtension=".json" mimeType="application/json" />
         </staticContent>
       </system.webServer>

However, I do not know which web server S3 is using so after I deploy there, the JSON call fails and my website looks crap because the call to the static .json file fails.

A network trace on my website at http://presentations.sukul.org/ will show that the call to Presentations.txt (I have also tried Presentations.json) will fail with a 404 error. The same setup works locally in Visual Studio debugging.

So in short, what I am asking for is whether there is a way to enable the application/json mime type so that the $.ajax call succeeds in a static website hosted on Amazon S3 callling a static .json file hosted in the same website?

Thanks in advance.

Upvotes: 0

Views: 2101

Answers (1)

Shailen Sukul
Shailen Sukul

Reputation: 510

Nevermind, I was overthinking this.

The only issue I had was with case sensitivity. So /json/Presentations.txt is NOT the same as /Json/Presentations.txt. Going from a Windows to a presumably *nix environment on Amazon S3 tripped me, but diagnosing the network trace gave me clues that it was not finding the JSON file.

All working fine now after making the necessary edits.

Upvotes: 1

Related Questions