Octet Stream Encoding

Posted by admin
Octet Stream Encoding Average ratng: 3,1/5 4247 votes

I'm connecting to an IIS server using transfer-encoding: chunked but the server just hangs there unless the client sends a 0 r n as the first chunk. The same scenario works flawlessly with PHP (A. Indefinite form. This does not encode the length at all, but that the content octets finish at marker octets. This applies to constructed types and is typically used if the content is not immediately available at encoding time. It consists of single octet, in which bit 8 is 1, and bits 1–7 are 0. HTTP Response with an octet-stream version of same file, in UTF-8 encoding (I assume) Here is what I know: I pulled the Message Body of the response from the server and dropped it to file.

  1. location.href = 'data:application/octet-stream;base64,' + appendPDFContentHere
  2. <a href='data:application/octet-stream;base64,appendPDFContentHere'>pdf</a>
  3. /**
  4. * Base64 encode / decode
  5. *
  6. _keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
  7. // public method for encoding
  8. var output = ';
  9. var chr1, chr2, chr2raw, chr3, chr3raw, enc1, enc2, enc3, enc4;
  10. chr2 = isNaN(chr2raw = input.charCodeAt(i++)) ? NaN : (chr2raw & 0xFF);
  11. chr3 = isNaN(chr3raw = input.charCodeAt(i++)) ? NaN : (chr3raw & 0xFF);
  12. enc1 = chr1 >> 2;
  13. enc3 = ((chr2 & 15) << 2) (chr3 >> 6);
  14. enc3 = enc4 = 64;
  15. enc4 = 64;
  16. this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
  17. this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
  18. }
  19. return output;
  20. }
  21. // http://web.archive.org/web/20071103070418/mgran.blogspot.com/2006/08/downloading-binary-streams-with.html
  22. //fetches BINARY FILES synchronously using XMLHttpRequest
  23. load_url = function(url) {
  24. req.open('GET',url,false);
  25. //XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
  26. req.overrideMimeType('text/plain; charset=x-user-defined');
  27. alert(req.status);
  28. }
  29. }
  30. function getDataURI(filename)
  31. var file = load_url(filename);
  32. var uri = 'data:application/octet-stream;base64,' + encodeURIComponent(uueFile);
  33. }
  34. window.addEventListener('load',
  35. {
  36. document.getElementById('myDiv').innerHTML += '<a href=' + link + '><code>' + link + '</code></a><br><br>';

Join GitHub today

GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.

Sign up New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments

commented Nov 9, 2017
edited

Hi, thank you for the amazing repo!

Instead of Content-Type: text/csv is it possible to set Content-Type as application/octet-stream for the attached csv files?

thank you
Radoslaw

commented Nov 9, 2017

Hey, thanks for posting. I'm not sure why you would want that :)? It would help understanding how it would fit in the code.

Octet Stream Encoding

commented Nov 10, 2017

Thank you Pascal for your prompt reply. Based on my understanding all csv files send via yagmail are detected as 'Content-Type: text/csv; name='some_filename.csv' which is very nice feature because the content of the csv file is directly displayed inline in the body of the email.

But for my case I would like to display the attachments as the attachements. See the screenshot.

Thank you.
Have a wonderful weekend!
Radoslaw

Introducing the XLSTAT Free edition. Free statistical features in Excel. To celebrate XLSTAT's 20th anniversary. The version will appear automatically in your MS Excel interface if you are not using a trial version of XLSTAT or if your XLSTAT license key has expired. Xlstat free trial. ** The XLSTAT trial version which includes over 200+ features can be used for 14 days free of charge. Once your trial expires, you'll be given the option to either purchase one of our licensed solutions or continue using a limited version of XLSTAT for free. XLSTAT License; Using XLSTAT without a license. Using XLSTAT without a license key: XLSTAT free 2018-12-03. Using the XLSTAT free version. Once your 14-Day trial period has ended, the free limited edition of XLSTAT will be automatically activated on your computer. Activate the 14 day free XLSTAT trial When XLSTAT is launched for the first time, a window will pop up (see below). In order to activate your trial license, please click on the indicated button.

commented Nov 11, 2017
edited

Hi Radoslaw, just a guess.. but are you mentioning the csv in contents or in attachments? In case you cannot get it to work with using attachments, it's most likely a bug. You too, enjoy the weekend :-)

commented Nov 11, 2017

Hi Pascal, yes I'm using attachments. See the code and zipped csv.

smtp.send(to=myemail, subject='test1', attachments='/path/123_ARIADNA-10-2017.csv' )
123_ARIADNA-10-2017.csv.zip

Thank you
Radoslaw

added a commit that referenced this issue Nov 11, 2017

commented Nov 11, 2017

Could you try to see if it works for you with yagmail-0.10.209?

commented Nov 11, 2017

No luck.

print(yagmail.__version__)
shows: 0.10.209
but I'm still getting the same results.

here are the raw content of the email:

commented Nov 11, 2017
edited

I think I misunderstood the question!

For me in gmail, the csv shows just fine (not inline, but as attachment). But you want application/octet-stream as type? Why? Isn't the type of a .csv file 'text/csv'?

commented Nov 12, 2017
edited

Yes it works on gmail web client.
The issue has something to do with the mac Mail App (desktop & ios)
If you have macOS or iPhone when you will see that the csv attachments are displayed inline.

See the part of the raw source, email send via perl's MIME::Lite + Net:SMTP, which works:

based on my research adding Content-Disposition: attachment with Content-Type: application/csv should work
in the meantime a small amendment in sender.py did the trick ;)

changed the titleContent-Type: application/octet-stream for the csv filesNov 12, 2017

commented May 4, 2018

Had the same problem, still a bug at v0.10.212. @radoslawoska fix works.
CSV attachments sent with yagmail can't be read properly on gmail client running on apple systems on current version. Its really important ^^.
cheers!

commented May 4, 2018

I have missed this one, thanks for bringing it back to attention. Feel free to make a PR as you've already found the fix, I'd gladly accept it and put it on pypi!

added a commit to amrutadotorg/yagmail that referenced this issue Nov 5, 2018

csv files proper handling in the Mac mail client
Verified
This commit was created on GitHub.com and signed with a verified signature using GitHub’s key.
GPG key ID: 4AEE18F83AFDEB23Learn about signing commits

referenced this issue Nov 5, 2018

Open

csv files proper handling in the Mac mail client #129

commented Nov 5, 2018

thank you, PR created

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment