Skip to content

Commit b35cc87

Browse files
author
Hubot
committed
Sync changes from upstream repository
1 parent 05e2428 commit b35cc87

3 files changed

Lines changed: 51 additions & 10 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
kind: change
3+
title: "Changes to Gist API response for large files"
4+
created_at: 2014-05-06
5+
author_name: leongersing
6+
---
7+
8+
In order to provide a faster, more robust API for Gist, we are making two changes to better handle large files in [Gist API responses][gist-json-representation].
9+
10+
### Truncating file contents larger than one megabyte
11+
12+
The [Gist API response][gist-json-representation] includes data for every file in the Gist. That works well for Gists with reasonably-sized files. When a Gist contains large files, however, it can lead to timeouts when preparing or sending the API response.
13+
14+
To eliminate those timeouts, the API now limits the amount of content returned for each file. If a file is larger than one megabyte in size, the API response will include the first megabyte of content for that file. (Few Gists have files this large. As a result, most API clients won't notice any impact from this change.)
15+
16+
### New "truncated" attribute
17+
18+
The JSON snippet below illustrates the attributes provided for each file in the Gist API response. In it, you'll notice a new `truncated` attribute included as part of the file metadata. This Boolean attribute indicates whether the `content` value is truncated for this request.
19+
20+
{
21+
files: {
22+
"my_large_file.md": {
23+
"size": 2097152,
24+
"content": "Large content. Truncated at end of first megabyte. [...]",
25+
"truncated": true,
26+
"raw_url": "https://raw.githubusercontent.com/[...]/my_large_file.md",
27+
"type": "text/plain",
28+
"language": "Markdown"
29+
}
30+
}
31+
}
32+
33+
### Getting the full content for truncated files
34+
35+
We recognize that sometimes you'll still want the full content for a file, even if it's too large to get returned in the standard Gist API response. For files under 10 megabytes, simply make a request to the URL specified in the `raw_url` attribute, and you'll receive the complete content for that file. For larger files, you'll need to clone the gist locally via the ```git_pull_url``` to access the full file contents.
36+
37+
If you have any questions, don’t hesitate to [get in touch][contact].
38+
39+
[contact]: https://github.com/contact?form[subject]=Gist+API+now+truncates+large+files
40+
[gist-json-representation]: /v3/gists/#detailed-gist-representation

content/v3/gists.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Name | Type | Description
4949

5050
GET /gists/:id
5151

52-
### Response
52+
### Response {#detailed-gist-representation}
5353

5454
<%= headers 200 %>
5555
<%= json :full_gist %>

lib/resources.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,20 +1214,21 @@ def text_html(response, status, head = {})
12141214

12151215
GIST_FILE = {
12161216
"ring.erl" => {
1217-
"size" => 932,
1218-
"raw_url" => "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
1219-
"type" => "text/plain",
1220-
"language" => "Erlang"
1217+
"size" => 932,
1218+
"raw_url" => "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
1219+
"type" => "text/plain",
1220+
"language" => "Erlang"
12211221
}
12221222
}
12231223

12241224
GIST_FILE_WITH_CONTENT = {
12251225
"ring.erl" => {
1226-
"size" => 932,
1227-
"raw_url" => "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
1228-
"type" => "text/plain",
1229-
"language" => "Erlang",
1230-
"content" => "contents of gist"
1226+
"size" => 932,
1227+
"raw_url" => "https://gist.githubusercontent.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl",
1228+
"type" => "text/plain",
1229+
"language" => "Erlang",
1230+
"truncated" => false,
1231+
"content" => "contents of gist"
12311232
}
12321233
}
12331234

0 commit comments

Comments
 (0)