Pack JSON has some new fields for the live update process:
id
project-slug
size
- Human readible size of pack with all assets. Eg. "5mb"etag
- This is supplied in the HTTP ETag header but provided in the JSON as well.
Request the latest pack:
https://fx.sna.pr/projects/ project-slug
/ filter or sticker
-packs/latest/ filter or sticker
-pack.json
https://fx.sna.pr/projects/cool-cat/sticker-packs/latest/sticker-pack.json
To make this as efficient as possible we use ETags.
Requests for latest
should include the If-None-Match
header. If there is no
pack update the server will respond with HTTP 304
(Not Modified). Otherwise
the new JSON will be returned with a new ETag in the HTTP ETag
header. (See example below)
Use the JSON file contents to find and download the assets.
Assets are located relative to the JSON file.
You should use the pack ID, not 'latest' - if a new pack is released while you are downloading assets 'latest' will change and break your download.
https://fx.sna.pr/projects/cool-cat/sticker-packs/3/cover.png https://fx.sna.pr/projects/cool-cat/sticker-packs/3/assets/hat.png https://fx.sna.pr/projects/cool-cat/sticker-packs/3/assets/thumbs/hat.png
https://fx.sna.pr/projects/hipster/filter-packs/7/cover.png https://fx.sna.pr/projects/hipster/filter-packs/7/filters/rainbow/filter.json https://fx.sna.pr/projects/hipster/filter-packs/7/filters/rainbow/thumb.png https://fx.sna.pr/projects/hipster/filter-packs/7/filters/rainbow/vignette.png
A specific pack JSON can be requested from this URL:
https://fx.sna.pr/projects/ project-slug
/ filter or sticker
-packs/ pack-id
/ filter or sticker
-pack.json
https://fx.sna.pr/projects/cool-cat/sticker-packs/3/sticker-pack.json https://fx.sna.pr/projects/hipster/filter-packs/7/filter-pack.json
- User downloads cool-cat app with filter pack included. (filter-pack.json contains
"etag": "65g4"
) - User opens app
- App requests https://fx.sna.pr/projects/cool-cat/filter-packs/latest/filter-pack.json with HTTP Header
If-None-Match: "65g4"
- Server returns
HTTP 304
- After 1 day, user opens app again
- App requests https://fx.sna.pr/projects/cool-cat/filter-packs/latest/filter-pack.json with HTTP Header
If-None-Match: "65g4"
- Server returns
HTTP 200
and new JSON - App tells user 'A new filter pack is available (5mb), would you like to downlaod it now?'
- App uses JSON contents to find and download all assets in the pack.
- Once downloads have succeeded the old pack is replaced.