Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

It's possible to store json on amazon s3?

I would like to store json file to my amazon s3 and then retrieve it with ajax request. Unfortunately it seems s3 does not allow content-type application/json....

I should save my file as text/plain and then add header with php?

like image 273
Tropicalista Avatar asked Jun 13 '13 12:06

Tropicalista


People also ask

Can I store JSON in S3?

Amazon S3 Select works on objects stored in CSV, JSON, or Apache Parquet format. It also works with objects that are compressed with GZIP or BZIP2 (for CSV and JSON objects only), and server-side encrypted objects.

Does AWS support JSON?

AWS Glue retrieves data from sources and writes data to targets stored and transported in various data formats. If your data is stored or transported in the JSON data format, this document introduces you available features for using your data in AWS Glue. AWS Glue supports using the JSON format.

What kind of data can I store in Amazon S3?

You can store virtually any kind of data in any format. Please refer to the Amazon Web Services Licensing Agreement for details. Q: How much data can I store in Amazon S3? The total volume of data and number of objects you can store are unlimited.

Can you store JSON?

You can store JSON documents in SQL Server or SQL Database and query JSON data as in a NoSQL database. This article describes the options for storing JSON documents in SQL Server or SQL Database.


2 Answers

I have found the problem. I was parsing the json in the wrong way.

$.ajax({
    url:"https://s3.amazonaws.com/myBucket/myfile.json",
    type:"GET",
    success:function(data) {
            console.log(data.property)
    }
})

Instead this works:

$.ajax({
    url:"https://s3.amazonaws.com/myBucket/myfile.json",
    type:"GET",
    success:function(data) {
        var obj = jQuery.parseJSON(data);
        if(typeof obj =='object'){
            console.log(obj.property)
        }
    }
})
like image 56
Tropicalista Avatar answered Oct 09 '22 02:10

Tropicalista


Change Metadata 'Value' in Key:Value pair to 'Application/json' from file properties, in AWS S3 console.

like image 27
Dilshad PT Avatar answered Oct 09 '22 04:10

Dilshad PT