diff --git a/src/couch_att.erl b/src/couch_att.erl index 9d38cfae..d811133f 100644 --- a/src/couch_att.erl +++ b/src/couch_att.erl @@ -438,17 +438,30 @@ digest_from_json(Props) -> to_json(Att, OutputData, DataToFollow, ShowEncoding) -> - [Name, Data, DiskLen, AttLen, Enc, Type, RevPos, Md5] = fetch( + [ExtStoreID,AttExternalSize, AttExternalMD5] = couch_att:fetch([att_extstore_id, + att_extstore_size, + att_extstore_md5], Att), + [Name, Data, DiskLenTmp, AttLen, Enc, Type, RevPos, Md5] = fetch( [name, data, disk_len, att_len, encoding, type, revpos, md5], Att ), + case ExtStoreID of + undefined -> + DiskLen = DiskLenTmp, + DigestProp = case base64:encode(Md5) of + <<>> -> []; + Digest -> [{<<"digest">>, <<"md5-", Digest/binary>>}] + end; + _ -> + DiskLen = AttExternalSize, + DigestProp = case AttExternalMD5 of + <<>> -> []; + Digest -> [{<<"digest">>, <<"md5-", Digest/binary>>}] + end + end, Props = [ {<<"content_type">>, Type}, {<<"revpos">>, RevPos} ], - DigestProp = case base64:encode(Md5) of - <<>> -> []; - Digest -> [{<<"digest">>, <<"md5-", Digest/binary>>}] - end, DataProps = if not OutputData orelse Data == stub -> [{<<"length">>, DiskLen}, {<<"stub">>, true}];