Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query > Asset's URL does not work #48

Closed
heapwalker opened this issue Aug 9, 2016 · 4 comments
Closed

Query > Asset's URL does not work #48

heapwalker opened this issue Aug 9, 2016 · 4 comments
Assignees

Comments

@heapwalker
Copy link

heapwalker commented Aug 9, 2016

We upload an image file to server using JS SDK, to our own table news_stress_image, which has a column photo referencing the table _asset. Then we queried the table news_stress_image and wanted to get the (publicly accessible) image url.

The raw json result from the SDK's web service is captured:

{
    "result": [
        {
            "_access": [
                {
                    "level": "read",
                    "public": true
                }
            ],
            "_created_at": "2016-08-09T07:57:35.219725Z",
            "_created_by": "22de813c-b277-4e72-99a6-c514a8bc8e6a",
            "_id": "news_stress_image/71fb8c6a-31c2-4f1b-bab8-0d98c511a4b7",
            "_ownerID": "22de813c-b277-4e72-99a6-c514a8bc8e6a",
            "_type": "record",
            "_updated_at": "2016-08-09T07:57:35.219725Z",
            "_updated_by": "22de813c-b277-4e72-99a6-c514a8bc8e6a",
            "news_stress_id": {
                "$id": "news_stress/fdbb4b77-0030-446c-979c-4d51fec65dfd",
                "$type": "ref"
            },
            "photo": {
                "$name": "180180b3-eb17-4a0c-8309-97da9444e677-news-stress-image",
                "$type": "asset",
                "$url": "https://s3-ap-northeast-1.amazonaws.com/cloudpillar-sky-test/180180b3-eb17-4a0c-8309-97da9444e677-news-stress-image"
            }
        },
        ...
    ]
}

The returned url at record.photo.url -- https://s3-ap-northeast-1.amazonaws.com/cloudpillar-sky-test/180180b3-eb17-4a0c-8309-97da9444e677-news-stress-image -- does not works. An error xml string stating "Access Denied" is returned.

From docs https://docs.skygear.io/js/guide/asset, we saw in the comment:

  // if configured properly, the url should look like the following
  // <ASSET_STORE_URL_PREFIX>/<asset-id>-<your-asset-name>

Then logging into Skygear Developer Portal and we saw that the environment variable ASSET_STORE_URL_PREFIX is having value https://skygearprototype.staging.skygeario.com/files. Thus the url https://skygearprototype.staging.skygeario.com/files/180180b3-eb17-4a0c-8309-97da9444e677-news-stress-image works actually but wasn't returned from SDK.

Would please advise whether there are some mistakes in our environment variables?

@heapwalker heapwalker changed the title Asset's URL does not work Query > Asset's URL does not work Aug 9, 2016
@rickmak
Copy link
Member

rickmak commented Aug 9, 2016

If all your asset is public, you should specific the ASSET_STORE_PUBLIC to YES. Refs: https://docs.skygear.io/server/guide#configure

If you want skygear generate a signed URL for per asset, set ASSET_STORE_PUBLIC to NO

@heapwalker
Copy link
Author

Confirmed that we had already set ASSET_STORE_PUBLIC to YES.

@rickmak rickmak self-assigned this Aug 10, 2016
@rickmak
Copy link
Member

rickmak commented Aug 10, 2016

@cpryanpang I see the asset is uploaded to s3 correctly. Would you please help to check following so i get more hints on whats going wrong.

  1. is Static Website Hosting enabled on s3?
  2. Is the ASSET_STORE_ACCESS_KEY provided in developer portal have right to modify the resource permission(s3:PutBucketAcl, s3:PutObjectAcl and s3:PutObjectVersionAcl) refs: http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#SpecifyingGrantee

@heapwalker
Copy link
Author

heapwalker commented Aug 10, 2016

@rickmak Thanks your hint. We configured the s3 setting and we can access the image now. So this issue was not caused by skygear SDK. Thx a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants