可以将json存放在亚马逊s3上吗? [英] It's possible to store json on amazon s3?

查看:212
本文介绍了可以将json存放在亚马逊s3上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将json文件存储到我的amazon s3中,然后使用ajax请求检索它。不幸的是,似乎s3不允许内容类型的应用程序/ json ....

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

我应该将文件保存为text / plain然后用php添加标题?

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

推荐答案

我发现了问题。我正在以错误的方式解析json。

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)
    }
})

取而代之的是:

$.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)
        }
    }
})

这篇关于可以将json存放在亚马逊s3上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆