Uploading multi-line Caption via upload.smugmug.com

oceanboyoceanboy Big grinsPosts: 20Registered Users Big grins
When uploading using upload.smugmug.com, the caption can be set by including an X-Smug-Caption: header field. This is fine for simple captions, but fails when the caption contains embedded newlines (and perhaps other characters). Is there a way to encode arbitrary characters during HTTP transport that SmugMug accepts?

Comments

  • thenickdudethenickdude Software developer Dunedin, New ZealandPosts: 1,301Registered Users Major grins
    edited April 27, 2014
    Hm, HTTP headers can (in theory) be extended over multiple lines by prefixing additional lines by some whitespace (spaces or tabs):

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html

    So, for example:
    X-Smug-Caption: This is an example caption
     Second line of caption
    

    It's worth a try...
  • oceanboyoceanboy Big grins Posts: 20Registered Users Big grins
    edited April 27, 2014
    Hi Lamah,

    Yes, of course HTTP header fields may extend over multiple lines, but when doing so, the line folding is done for transport only. The line breaks are not part of the header field content. What I'm asking about is the opposite situation: when the content of the header field contains actual line breaks, they must be encoded for transport, so they are not visible at the HTTP level. Among the possibilities are backslash-encoding (per RFC 2616) or RFC 5987 encoding. The key question is, what does SmugMug support? RFC 5987 requires adding a trailing asterisk to the header field name, and the value starts with a charset and then an encoding of the values, so obviously it's a more complex endeavor.

    I've tried simple backslash encoding, but I always get an error "Uploading is Temporarily Disabled. Please Retry Later." I think the server is returning the wrong error, that it's actually a problem with the content.
  • oceanboyoceanboy Big grins Posts: 20Registered Users Big grins
    edited April 27, 2014
    Wow, RFC 5987 encoding works!
    I decided to, as the Australians say, "suck it and see." So I modified my code to do RFC 5987 encoding, and it works!

    The caption:
    This is line one.
    This is line two.

    This is line four (line three was blank).
    Lots of "special" and 'funny' characters might lurk here, you know?
    When sent in the X-Smug-Caption header, ends up as:
    X-Smug-Caption*:UTF-8''This%20is%20line%20one.%0dThis%20is%20line%20two.%0d%0dThis%20is%20line%20four%20%28line%20three%20was%20blank%29.%0dLots%20of%20%22special%22%20and%20%27funny%27%20characters%20might%20lurk%20here,%20you%20know%3f
    

    After the upload, the image caption is correct:
    This is line one.
    This is line two.
    
    This is line four (line three was blank).
    Lots of "special" and 'funny' characters might lurk here, you know?
    
  • thenickdudethenickdude Software developer Dunedin, New ZealandPosts: 1,301Registered Users Major grins
    edited April 27, 2014
  • oceanboyoceanboy Big grins Posts: 20Registered Users Big grins
    edited April 27, 2014
    Yeah, it's pretty cool.

    I'm about ready to make my shell script available. I use it on MacOS to upload images and videos. It optionally pulls caption and keywords from GraphicConverter for both images and videos, which is something the stock OS X uploaders don't do. It also optionally selected files that either have or don't have a label color set. It also updates images/videos if you've edited the caption or keywords in your local copy.
  • oceanboyoceanboy Big grins Posts: 20Registered Users Big grins
    edited April 28, 2014
    Doesn't work for videos
    Weird. Images work fine, but videos drop the caption. The upload code is identical in both cases.
Sign In or Register to comment.