Skip to content

Conversation

@smashwilson
Copy link
Member

This is necessary to support assets supplied as part of a layout, the second half of deconst/deconst-docs#13.

My goal is that, if you provide an optional ?layout=true query parameter to an asset upload:

curl -s -F [email protected] http://content:9000/assets?layout=true

... an additional key called assetname will be provided to the handlebars layout during every page render, with a value that's the SSL URI of the fingerprinted someasset.jpg file on the CDN.

@smashwilson
Copy link
Member Author

The tricky part here is that it's the first time we need non-Cloud Files state in the content service.

I'm probably going to use MongoDB because Strider uses it as well.

@smashwilson
Copy link
Member Author

Looking good:

$ curl -s -F txt_somefile_url=@somefile http://docker:9000/assets?layout=true | python -m json.tool
{
    "drcmap": "https://8c782371ed443340bfce-a76b79aca86ab4305e3e9ef5c9a01022.ssl.cf1.rackcdn.com/somefile-89c680cb317c66e5f553ca02049f702228495d716f4d1349d4cb1c2a66292d1b"
}
$ curl -s http://docker:9000/content/https%3A%2F%2Fgithub.amrom.workers.dev%2Fdeconst%2Fdeconst-docs | python -m json.tool
{
    "assets": {
        "txt_somefile_url": "https://8c782371ed443340bfce-a76b79aca86ab4305e3e9ef5c9a01022.ssl.cf1.rackcdn.com/somefile-89c680cb317c66e5f553ca02049f702228495d716f4d1349d4cb1c2a66292d1b"
    },
    "body": "...."
}

I'm not that fond of ?layout=true as a query parameter, though. I'll think of something better to replace it with next.

@smashwilson smashwilson changed the title [wip] Apply a name to assets when requested. Apply a name to assets when requested. Apr 10, 2015
@smashwilson
Copy link
Member Author

There we go:

$ curl -s -F txt_somefile_url=@somefile http://docker:9000/assets?named=true | python -m json.tool
{
    "somefile": "https://8c772371dd443340bfce-a76b79aca86ab4305d3e9ef5c9a01022.ssl.cf1.rackcdn.com/somefile-b027376173d89c6b852bfa1da922997c9b12c8a113426e415a55c9a63a0327f0"
}
$ curl -s http://docker:9000/content/https%3A%2F%2Fgithub.amrom.workers.dev%2Fdeconst%2Fdeconst-docs | python -m json.tool
{
    "assets": {
        "txt_somefile_url": "https://8c772371dd443340bfce-a76b79aca86ab4305d3e9ef5c9a01022.ssl.cf1.rackcdn.com/somefile-b027376173d89c6b852bfa1da922997c9b12c8a113426e415a55c9a63a0327f0"
    },
    "body": "..."
}

smashwilson added a commit that referenced this pull request Apr 10, 2015
Apply a name to assets when requested.
@smashwilson smashwilson merged commit cef774a into deconst:master Apr 10, 2015
@smashwilson smashwilson deleted the register-named-assets branch April 10, 2015 14:10
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

Successfully merging this pull request may close these issues.

1 participant