<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amey Patil on Medium]]></title>
        <description><![CDATA[Stories by Amey Patil on Medium]]></description>
        <link>https://medium.com/@ameykpatil?source=rss-df4c80a03c24------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oNA_-OnLpkTFKZcb.jpg</url>
            <title>Stories by Amey Patil on Medium</title>
            <link>https://medium.com/@ameykpatil?source=rss-df4c80a03c24------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 05:21:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ameykpatil/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[An ordinary average boy]]></title>
            <link>https://medium.com/ameykpatil/an-ordinary-average-boy-5e9c2fd2cea6?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e9c2fd2cea6</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[scribbles]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 23:48:37 GMT</pubDate>
            <atom:updated>2020-06-22T23:48:37.424Z</atom:updated>
            <content:encoded><![CDATA[<p><em>You are just an ordinary average boy<br>It’s a crime to expect all the fun and joy<br>The only option for you is to study hard<br>Stay ahead of the others in the report card</em></p><p><em>The field with well paying jobs that’s your career<br>Where the parents happiness won’t be a barrier<br>At your age you don’t even know your passion<br>Even if you do, you can’t afford to take action</em></p><p><em>So what, if you have crush on that cute college girl<br>You have to crush those feelings and pop the bubble<br>It’s better to admit that she is way out of your reach<br>You are just a muddy pond and she is a sunny beach</em></p><p><em>You have got a job but is the money enough<br>Do you want to make life easy or even more tough<br>Your innocent parents might think the son has made it<br>But you know the truth you are too afraid to admit</em></p><p><em>Have you thought about the new apartment?<br>Or are you gonna ask your family to live in a tent?<br>You need to focus on working day and night<br>Maybe the raise you need might come in sight</em></p><p><em>I know you are genuinely a warm and nice guy<br>People always want you as a shoulder to cry<br>In the dark night &amp; lonely road you change the side<br>Just so the girl walking ahead has a comfortable ride</em></p><p><em>You try to listen to everyone with great deed<br>You go extra mile for your people when in need<br>But in this world, for help, you will need to scream loud<br>Coz listening to the listeners is not a thing for this crowd</em></p><p><em>What can you do than to swallow your frustrations<br>You are nothing but your responsibilities &amp; expectations<br>It’s impossible to figure out your life in an entire lifespan<br>After all you are just an ordinary average man!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWhUYPERFv-j3TkcdUZvIQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@karthikhimself?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Karthik Thoguluva</a> on <a href="https://unsplash.com/@karthikhimself?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e9c2fd2cea6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/an-ordinary-average-boy-5e9c2fd2cea6">An ordinary average boy</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s not push]]></title>
            <link>https://medium.com/ameykpatil/lets-not-push-f17540561979?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/f17540561979</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[couples]]></category>
            <category><![CDATA[scribbles]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Sun, 01 Mar 2020 22:03:48 GMT</pubDate>
            <atom:updated>2020-03-01T22:04:16.370Z</atom:updated>
            <content:encoded><![CDATA[<p>मी local चा प्रवासी,<br>तु car वासी.<br>मी relaxed आणि raw,<br>तु uptown आणि classy.</p><p>मी long queue,<br>तु‌ VIP zone.<br>मी cheap वाला android<br>तु latest iPhone.</p><p>मी local brands<br>तु Zara आणि Armani.<br>मी साधा ice-cream cone,<br>तु sizzling chocolate brownie.</p><p>मी झऱ्याचे पाणी, <br>तु Bisleri bottle.<br>मी backpack आणि tent, <br>तु trolley आणि luxury hotel.</p><p>मी आहे माझ्या जगात happy,<br>तु पण राहशील तुझ्या life मध्ये खुश.<br>आपण नाही meant for each other,<br>Please नको करूया उगाच push.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NoxHpVDHF0VY4CW9Np3qqg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@halfcadence?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Andrew Shiau</a> on <a href="https://unsplash.com/s/photos/opposite?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f17540561979" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/lets-not-push-f17540561979">Let’s not push</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unfair]]></title>
            <link>https://medium.com/ameykpatil/unfair-492e811d7893?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/492e811d7893</guid>
            <category><![CDATA[love]]></category>
            <category><![CDATA[scribbles]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Thu, 18 Jul 2019 11:20:30 GMT</pubDate>
            <atom:updated>2019-07-18T11:28:05.207Z</atom:updated>
            <content:encoded><![CDATA[<p><em>There will be a world somewhere<br>where you &amp; me are together<br>just you just me and<br>our feelings would be there</em></p><p><em>Where the morning will start <br>with the rays of your eyes<br>&amp; the lullaby at night will be<br>in your arms under the blue skies</em></p><p><em>Don’t know where is that world<br>Don’t know if it is even there<br>Where my life won’t be unhappy<br>Where my life won’t be unfair</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKNkm5JIxfFGaY1YGIyzhg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@fabrizioverrecchia">Fabrizio Verrecchia</a> on <a href="https://unsplash.com/">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=492e811d7893" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/unfair-492e811d7893">Unfair</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to publish an external video to Twitter — Node.js version]]></title>
            <link>https://medium.com/ameykpatil/how-to-publish-an-external-video-to-twitter-node-js-version-89c03b5ff4fe?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/89c03b5ff4fe</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Mon, 15 Oct 2018 10:00:43 GMT</pubDate>
            <atom:updated>2018-10-15T10:08:13.602Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to publish an external video to Twitter — Node.js version</h3><h4><strong>How does image or video publishing generally work with Twitter API?</strong></h4><p>The way image or video can be published on twitter involves more than a single step. First, you have to upload a media to twitter using Upload API.<br>This returns a media id for the uploaded media. Now, in the second step you have to call Twitter’s API to Publish a new tweet. While calling this API you will need to specify the media id, so that twitter includes the uploaded media with this tweet. Below is the API to Publish a new tweet.</p><p><a href="https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update.html">POST statuses/update</a></p><h4>There are 2 ways to upload a media to Twitter</h4><p>Direct Upload : Media can be uploaded using a POST media/upload API of Twitter. This is a simple image upload endpoint, which does not provide all the features. This API supports only certain types of media which does not include gif &amp; video. So you can actually just upload media of type image using this API. Even for image there is a size restriction which is around 3MB. This is not officially documented but many developers have faced this limit while using this API. Response returns media_id (or media_id_string) which can be then passed with POST statuses/update API mentioned above.</p><p><a href="https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload">POST media/upload</a></p><p>Chunked Upload : The alternative to Direct Upload is the chunked upload endpoint. A media is divided into multiple chunks. Each chunk is then uploaded separately one after another. After all the chunks have been uploaded media_id (or media_id_string) can be then passed with POST statuses/update.</p><p>Following are the various APIs which in combination makes Chunked Upload of media successful.</p><p>INIT — The INIT command request is used to initiate a file upload session. It returns a media_id which should be used to execute all subsequent requests.</p><p><a href="https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-init.html">POST media/upload (INIT)</a></p><p>APPEND — The APPEND command is used to upload a chunk of the media file. A file could be split into number of chunks, and uploaded usingAPPEND command requests. For each chunk a separateAPPEND command needs to be called.</p><p><a href="https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-append">POST media/upload (APPEND)</a></p><p>FINALIZE — The FINALIZE command should be called after the entire media file is uploaded using APPEND commands.</p><p><a href="https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-finalize">POST media/upload (FINALIZE)</a></p><p>STATUS — If the response of the FINALIZE command contains a processing_info field, it may also be necessary to use a STATUS and wait for it to return success. The STATUS command is used to periodically poll for updates of media processing operation. After the STATUS command response returns succeeded, you can move on to the next step of Tweet creation.</p><p><a href="https://developer.twitter.com/en/docs/media/upload-media/api-reference/get-media-upload-status">GET media/upload (STATUS)</a></p><h4>Why is the chunked upload better?</h4><p>Chunked upload API supports static images, animated gifs as well as videos. It provides better reliability. It is a recommended way by Twitter for uploading media. It also allows pausing &amp; resuming of file uploads, which means you can allow users of your app to pause &amp; resume media upload. It is extremely necessary for the slow connections. Also, Twitter has clearly said that the new features will only be supported for the chunked upload endpoints.</p><h4>There are not enough examples showing efficient Chunked Upload</h4><p>There isn’t a library which gives an easy way to upload a media in chunks. Also, there are not enough examples available to start implementing chunked upload on your own. Even if there are few examples to show Chunked Upload they all rely on the fact that the media reside on your local machine. <br>The examples I found were -<br><a href="https://github.com/desmondmorris/node-twitter/tree/master/examples#chunked-media"><em>github.com/desmondmorris/node-twitter</em></a> — which shows how to upload media in chunks if it resides at the local path.<br><a href="https://lorenstewart.me/2017/02/03/twitter-api-uploading-videos-using-node-js/">lorenstewart.me/twitter-api-uploading-videos-using-node-js</a> — make use of Twit library but again it just shows how the local media can be uploaded.</p><p>Obviously you can download the file from external url or S3 or any other place to your local machine &amp; apply above methods to upload in chunks. You can then cleanup the downloaded media from local machine. <br>But wouldn’t it be better if we could just stream the media from external path to Twitter in chunks. That way we do not have to worry about cleaning stuff, also we do not have to download entire file &amp; then start the chunked upload. Chunk upload can be much more efficient if we could pull off the above way.</p><h4>So how can we implement this with Node.js?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEJRS0slgq3UGuSa3yTdIA.jpeg" /><figcaption>Overview of Chunked Upload to Twitter</figcaption></figure><p>(Please note, the code below uses <em>yield-generator</em> paradigm in most of its implementation. Yet to switch original implementation to <em>async-await</em>. So you will find a lot of code with <em>yield-generator</em> style along with few references of <em>promises</em> &amp; <em>callbacks</em>. We make use of <em>bluebird</em> library to switch between different styles.)</p><p>Let’s first define our basic objects required to be passed to the functions.</p><p>oAuthCredentials contains all the properties related to twitter credentials required for accessing twitter APIs.</p><pre>const oAuthCredentials = {<br>  &#39;consumer_key&#39;: &#39;TFtxxxxxxxxxxDtR4&#39;,<br>  &#39;consumer_secret&#39;: &#39;gjWH7xxxxxxxxxxxxxlQz&#39;,<br>  &#39;token&#39;: &#39;41xxxxx72–8Qaxxxxxxxxxxxx6aN&#39;,<br>  &#39;token_secret&#39;: &#39;bt8xxxxxxxxxxxxx7h9v&#39;<br>}</pre><p>videoObj contain the url of the video as well as the other metadata such as height, width, duration etc.</p><pre>const videoObj = {<br>  originalUrl: &#39;<a href="https://cf-media-poc.s3.amazonaws.com/742ee1452bc16075a6bf0f042575d5d4.mp4&#39;">https://tw-media-poc.s3.amazonaws.com/742ee.mp4&#39;</a>,<br>  videoMeta: {<br>    height: 123,<br>    width: 234,<br>    size: 1685018,<br>    duration: 120,<br>    mimeType: &#39;video/mp4&#39;<br>  }<br>}</pre><p>Now let’s write functions for each of the command of Twitter API involved in chunked upload.</p><p>Init — INIT command require details of the video such as mimeType (mp4, mpeg etc.) &amp; size in bytes. It returns a mediaId which is to be used in subsequent commands.</p><pre>const _initMediaUpload = function* (oAuthCredentials, videoObj) {<br>  const options = {<br>    url: &#39;<a href="https://upload.twitter.com/1.1/media/upload.json&#39;">https://upload.twitter.com/1.1/media/upload.json&#39;</a>,<br>    oauth: oAuthCredentials,<br>    formData: {<br>      command: &#39;INIT&#39;,<br>      &#39;media_type&#39;: videoObj.videoMeta.mimeType,<br>      &#39;media_category&#39;: &#39;tweet_video&#39;,<br>      &#39;total_bytes&#39;: videoObj.videoMeta.size<br>    }<br>  }<br>  try {<br>    const resultArray = yield requestPost(options)<br>    const resp = resultArray[0]<br>    const body = resultArray[1]<br>    const mediaId = JSON.parse(body).media_id_string<br>    return mediaId<br>  } catch (err) {<br>    throw err<br>  }<br>}</pre><p>Append — APPEND command accepts a chunk of data in base64 format, along with mediaId &amp; number of the chunk i.e. segment_index . This command should be called once for each chunk.</p><pre>const _appendMediaUpload = function* (oAuthCredentials, data, mediaId, segmentIndex) {<br>  const options = {<br>    url: &#39;<a href="https://upload.twitter.com/1.1/media/upload.json&#39;">https://upload.twitter.com/1.1/media/upload.json&#39;</a>,<br>    oauth: oAuthCredentials,<br>    form: {<br>      command: &#39;APPEND&#39;,<br>      &#39;media_id&#39;: mediaId,<br>      &#39;segment_index&#39;: segmentIndex,<br>      //media: data<br>      &#39;media_data&#39;: data.toString(&#39;base64&#39;)<br>    }<br>  }<br>  try {<br>    const resultArray = yield requestPost(options)<br>    return<br>  } catch (err) {<br>    throw err<br>  }<br>}</pre><p>Finalize — FINALIZE command should be called once all the chunks are uploaded using APPEND command. This is to tell Twitter that there are no more chunks left.</p><pre>const _finalizeMediaUpload = function* (oAuthCredentials, mediaId) {<br>  const options = {<br>    url: &#39;<a href="https://upload.twitter.com/1.1/media/upload.json&#39;">https://upload.twitter.com/1.1/media/upload.json&#39;</a>,<br>    oauth: oAuthCredentials,<br>    formData: {<br>      command: &#39;FINALIZE&#39;,<br>      &#39;media_id&#39;: mediaId<br>    }<br>  }<br>  try {<br>    const resultArray = yield requestPost(options)<br>    return<br>  } catch (err) {<br>    throw err<br>  }<br>}</pre><p>Status — STATUS command returns the status of the media that was uploaded. This is because Twitter does some type of processing to uploaded media. If the state is not succeeded the corresponding mediaId can not be used with POST statuses/update API. So one should always wait for the STATUS command to return a state as succeeded .</p><pre>const _getStatusMediaUpload = function* (<em>oAuthCredentials</em>, <em>mediaId</em>, <em>lastProgressPercent</em>) {<br>  const options = {<br>    url: &#39;https://upload.twitter.com/1.1/media/upload.json&#39;,<br>    oauth: <em>oAuthCredentials</em>,<br>    qs: {<br>      command: &#39;STATUS&#39;,<br>      &#39;media_id&#39;: <em>mediaId<br>    </em>}<br>  }</pre><pre>  try {<br>    const resultArray = yield requestGet(options)<br>    const body = <em>JSON</em>.parse(resultArray[1])</pre><pre>    if (body[&#39;processing_info&#39;]) {<br>      // if processing info is present return it<br>      const processingInfo = body[&#39;processing_info&#39;]<br>      return processingInfo<br>    } else if (body.errors) {<br>      // if body contains errors build message &amp; throw error <br>      const message = _.get(body, &#39;errors.0.message&#39;)<br>      const code = _.get(body, &#39;errors.0.code&#39;)<br>      throw new <em>Error</em>(`${code} ${message}`)<br>    } else {<br>      // else return custom processing info<br>      const processingInfo = {<br>        state: &#39;unknown&#39;,<br>        &#39;progress_percent&#39;: <em>lastProgressPercent<br>      </em>}<br>      return processingInfo<br>    }<br>  } catch (<em>err</em>) {<br>    throw <em>err<br>  </em>}<br>}</pre><p>Please note, in the above snippets, requestPost &amp; requestGet are just the promisified functions on top of the request library. Also, _ stands for lodash library.</p><pre>const _ = require(&#39;lodash&#39;)<br>const request = require(&#39;request&#39;)<br>const Promise = require(&#39;bluebird&#39;)<br>const requestPost= Promise.promisify(request.post,{multiArgs: true})<br>const requestGet = Promise.promisify(request.get, {multiArgs: true})</pre><p>Now Let’s try to integrate all the pieces together. We will first try to tie the APPEND &amp; FINALIZE part together which actually deals with the uploading directly. For this, we will open a stream for fetching a data from the video file. The approach will differ depending on where the video resides. I have mentioned both the ways with comments.</p><p>We are switching back to callback style to make use of events. Promise.coroutine helps us for calling generator functions inside a callback based flow.</p><p>For error event &amp; response event with non-ok http code we will return an error. For data event we will treat that data as chunk &amp; try to upload to twitter using _appendMediaUpload function. Once all the chunks have been uploaded we will call _finalizeMediaUpload function to tell Twitter that we have uploaded all the chunks. This step might happen in either data or end event. To synchronise between data &amp; end event, we use variables such as chunkUploadInProgress &amp; streamReadingEnded .</p><pre>const _streamMediaToTwitter = function (oAuthCreds, videoObj, mediaId, cb) {</pre><pre>  let segmentIndex = 0<br>  let chunkUploadInProgress = false<br>  let streamReadingEnded = false </pre><pre>  // if the video url is of S3  <br>  const filePath = videoObj.originalUrl<br>  const indexOfForwardSlash = filePath.lastIndexOf(&#39;/&#39;)<br>  const fileName = (indexOfForwardSlash !== -1) ? filePath.substr(indexOfForwardSlash + 1) : filePath<br>  const startIndex = &#39;<a href="https://&/#39;.length">https://&#39;.length</a><br>  const endIndex = filePath.indexOf(&#39;.s3.amazonaws.com&#39;)<br>  const bucket = filePath.slice(startIndex, endIndex)<br>  const params = {<br>    Bucket: bucket,<br>    Key: fileName<br>  }<br>  const res = s3.getObject(params).createReadStream()</pre><pre>  // if the video url is an external url<br>  const res = request.get(<em>videoObj</em>.originalUrl)</pre><pre>  res.on(&#39;response&#39;, function (resp) {<br>    if (resp.statusCode !== 200) {<br>      const error = new Error(`request failed : ${resp.statusCode}`)<br>      res.resume()<br>      return cb(error)<br>    }<br>  })</pre><pre>  res.on(&#39;error&#39;, function (err) {<br>    return cb(err)<br>  })</pre><pre>  res.on(&#39;data&#39;, function (chunk) {<br>    res.pause()<br>    chunkUploadInProgress = true<br>    Promise.coroutine(_appendMediaUpload)(oAuthCreds, chunk, mediaId, segmentIndex)<br>      .then(() =&gt; {<br>        segmentIndex++<br>        res.resume()<br>        chunkUploadInProgress = false<br>        Promise.resolve()<br>      })<br>      .then(() =&gt; {<br>        if (!chunkUploadInProgress &amp;&amp; streamReadingEnded) {<br>          Promise.coroutine(_finalizeMediaUpload)(oAuthCreds, mediaId)<br>            .then(() =&gt; {<br>              return cb(null, mediaId)<br>            })<br>        }<br>      })<br>      .catch((<em>err</em>) =&gt; <em>cb</em>(<em>err</em>))<br>  })</pre><pre>  res.on(&#39;end&#39;, function () {<br>    streamReadingEnded = true<br>    if (!chunkUploadInProgress &amp;&amp; streamReadingEnded) {<br>      Promise.coroutine(_finalizeMediaUpload)(oAuthCreds, mediaId)<br>        .then(() =&gt; {<br>          return cb(null, mediaId)<br>        })<br>    }<br>  })</pre><pre>}</pre><p>Now tie the remaining parts with the above function that we wrote for streaming media to Twitter. The remaining parts involves the very first &amp; last step i.e. _initMediaUpload which actually initiate the media upload &amp; _getStatusMediaUpload which gives the status of the processing of uploaded media. We will need to check the status repeatedly here.</p><pre>// initialize media upload &amp; get mediaId<br>const mediaId = yield _initMediaUpload(oAuthCredentials, <em>videoObj</em>)<br>    <br>// stream from the video url to twitter<br>yield Promise.promisify(_streamMediaToTwitter)(oAuthCredentials, <em>videoObj</em>, mediaId)</pre><pre>// check status &amp; wait till the media upload is finished<br>let state = &#39;pending&#39;<br>let progressPercent = 0 // you can print this to check progress<br>const startTime = <em>Date</em>.now()<br>do {<br>  const processingInfo = yield _getStatusMediaUpload (<em>oAuthCredentials</em>, <em>mediaId</em>, progressPercent)<br>  state = processingInfo.state<br>  progressPercent = processingInfo.progress_percent<br>} while (state !== &#39;succeeded&#39; &amp;&amp; (<em>Date</em>.now() - startTime) &lt; 30*1000)</pre><p>So now we have tied all the pieces together which are required to upload a media to Twitter.</p><p>Few points to note -</p><ul><li>While checking for the status of the progress, make sure you keep an exit way after certain period of time. (<em>Date</em>.now() — startTime) &lt; 30*1000 this condition was there for this exact purpose.</li><li>The implementation is with respect to video but it can be used even for images with minor tweaks such as changing media_category in INIT step.</li><li>Twitter has some strict conditions for the acceptable videos that can get published to Twitter through API, before starting the upload make sure your video is well within the limit. Limitations are listed <a href="https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices.html">here</a>.</li></ul><h4>This approach is going to be useful even for Facebook</h4><p>You would be glad to know that even Facebook API follows the similar concepts as like Twitter for media upload.</p><p>Facebook provides 2 ways to upload media just like Twitter. Facebook calls them as <em>Non-Resumable Upload </em>&amp;<em> Resumable Upload. Resumable Upload </em>is similar to<em> Chunked Upload</em> in Twitter. It has multiple steps which corresponds to the commands in Twitter described earlier. Read more about <em>Resumable Upload</em> of Facebook <a href="https://developers.facebook.com/docs/graph-api/video-uploads#resumable">here</a>.</p><p>So when you write a code for Twitter chunked upload. You can make it generic to be able to handle the Facebook media upload as well.</p><p>When I started working on this task, I faced lot of difficulties to make everything work with respect to <em>Node.js</em>. So when I was able to put everything in a proper way I decided to write this post. I hope this will be helpful to someone. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89c03b5ff4fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/how-to-publish-an-external-video-to-twitter-node-js-version-89c03b5ff4fe">How to publish an external video to Twitter — Node.js version</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A day to forget]]></title>
            <link>https://medium.com/ameykpatil/a-day-to-forget-5a9e04c06d09?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a9e04c06d09</guid>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[love]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[scribbles]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Tue, 08 May 2018 19:45:04 GMT</pubDate>
            <atom:updated>2018-05-08T19:45:04.760Z</atom:updated>
            <content:encoded><![CDATA[<p><em>One fine day when I was in her city<br>We decided to meet<br>How can I forget<br>A simple casual way we wanted to greet</em></p><p><em>It was a hot sunny day<br>&amp; I was waiting for her <br>But how can I forget<br>Even the wait was like a pleasant shower</em></p><p><em>There she came<br>Searching for me in a hurry<br>How can I forget<br>That face full of curiosity &amp; a little bit of worry</em></p><p><em>She saw me and <br>Worry turned into joy &amp; happiness<br>How can I forget <br>That shining beautiful face</em></p><p><em>We began to talk &amp; we continued<br>We talked, gossiped, chatted &amp; shared<br>How can I forget<br>The way we laughed &amp; the jaws flared</em></p><p><em>The plan was just a lunch<br>&amp; if possible a movie<br>How can I forget<br>Extended dinner &amp; a cutting tea</em></p><p><em>Leaning on my shoulder<br>and playing a thumb fight<br>How can I forget<br>While crossing the road holding my hand tight</em></p><p><em>I was loving her cute smile<br>&amp; a face with no lies<br>How can I forget<br>Drowning in her innocent yet deep eyes</em></p><p><em>Finally it was a time<br>I decided to leave<br>How can I forget<br>Opposing thoughts convincing me to believe</em></p><p><em>I wanted to kiss, I wanted to hug<br>This beautiful girl I met<br>But how can I forget<br>This was the day I had decided to forget</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NTktSDdm6RpErglTDylVow.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mfassphotos">Matthew Fassnacht</a> on Unsplash</figcaption></figure><p><em>*This piece was written in a very quick time &amp; I didn’t get time to review it again. Feedback &amp; corrections are appreciated.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a9e04c06d09" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/a-day-to-forget-5a9e04c06d09">A day to forget</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Free]]></title>
            <link>https://medium.com/ameykpatil/free-846477d5fdcc?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/846477d5fdcc</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <category><![CDATA[scribbles]]></category>
            <category><![CDATA[free]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Fri, 20 Apr 2018 19:51:49 GMT</pubDate>
            <atom:updated>2018-04-20T20:03:15.272Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Pack your bag &amp; travel with me,</em></p><p><em>Unexplored sights we shall see,</em></p><p><em>Breathe deep &amp; set yourself free,</em></p><p><em>From the cage you always wanted to flee!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ghaUWw7OeQ6UohTEtl75FA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kundeleknabiegunie">Agnieszka Boeske</a> on Unsplash</figcaption></figure><p><a href="https://www.instagram.com/p/Bdr3hk_nnCS"><em>*This post was originally published by me on Instagram as a caption of one of my clicks.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=846477d5fdcc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/free-846477d5fdcc">Free</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond ifs & buts]]></title>
            <link>https://medium.com/ameykpatil/beyond-ifs-buts-9b7630881c9b?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b7630881c9b</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[love]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <category><![CDATA[scribbles]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Fri, 06 Apr 2018 11:53:09 GMT</pubDate>
            <atom:updated>2018-04-06T11:53:09.138Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Saw her first at some wedding<br>Calm &amp; composed yet happiness spreading<br>Like a prayer to God<br>Like a face smiling broad</em></p><p><em>Not too dark not too fair<br>Tall &amp; slim playing with hair<br>I thought I should meet &amp; I should have a talk<br>It was just 10 feet yet I couldn’t walk</em></p><p><em>Life got busy, a year passed after that<br>I imagined I dreamed but not even a single chat<br>Then came another wedding, I saw her again<br>In a moment, vanished a year long regret &amp; a day long pain</em></p><p><em>Watching after so long, I couldn’t take eyes off her<br>But these relatives in the wedding seemed not to spare<br>The game of hide and seek went on for a while<br>Distance was few meters but felt like a mile</em></p><p><em>Finally a moment arrived to say goodbye<br>While I was still wondering how to say hi<br>Can’t blame destiny can’t blame my fate<br>Decided to swallow again all the regret</em></p><p><em>Few days passed &amp; I found a way<br>Added her on social network one fine day<br>Shared few hi hellos shared few pings<br>Tried my best but couldn’t share my feelings</em></p><p><em>Now I just dream what if another wedding came<br>Will it make a difference or story will be same<br>Life is getting busy with each passing day<br>Not sure at all when will I able to say</em></p><p><em>Is it really that difficult, to talk, to say, to express<br>Or is it just me creating all the mess<br>Years later, I’ll always regret what if I had few guts<br>what if I had gone beyond ifs &amp; buts<br>what if I had gone beyond ifs &amp; buts…</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHAEK2s5wPnZEgNf63H1cQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@masaagungg">Agung Pratamah</a> on Unsplash</figcaption></figure><p><a href="https://www.facebook.com/story.php?story_fbid=10153510859991340&amp;id=536056339"><em>*This piece was written few years back &amp; published originally on Facebook.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b7630881c9b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/beyond-ifs-buts-9b7630881c9b">Beyond ifs &amp; buts</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Camouflage]]></title>
            <link>https://medium.com/ameykpatil/camouflage-34e3d524129e?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/34e3d524129e</guid>
            <category><![CDATA[ameykpatil]]></category>
            <category><![CDATA[photos]]></category>
            <category><![CDATA[birds]]></category>
            <category><![CDATA[camouflage]]></category>
            <category><![CDATA[photography]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Wed, 04 Apr 2018 20:54:11 GMT</pubDate>
            <atom:updated>2018-04-04T20:54:11.061Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gaVuAD4yU4T7-UyA5AzylA.jpeg" /></figure><p>This amazing shot was clicked in Sept 2014 in Mumbai. When I was having my tea, I noticed it &amp; calmly but quickly I rushed towards my camera.</p><p>These birds are known as Barbets, they are tiny birds with a large head and a broad beak, often seen on trees that are fruiting. The <a href="http://en.wikipedia.org/wiki/Crimson-breasted_barbet">crimson-breasted barbet</a>, also called “Coppersmith Barbet” (तांबट in Marathi), with a black eyestripe and crimson and green colouration, is very common across India.</p><p>Due to their green colour they are easily camouflaged in surrounding trees. Then how do I able to capture it perfectly?</p><p><em>“The way to find a needle in a haystack is to sit down.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34e3d524129e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/camouflage-34e3d524129e">Camouflage</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Light]]></title>
            <link>https://medium.com/ameykpatil/light-46a431c933f3?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/46a431c933f3</guid>
            <category><![CDATA[ameykpatil]]></category>
            <category><![CDATA[photos]]></category>
            <category><![CDATA[diwali]]></category>
            <category><![CDATA[photography]]></category>
            <category><![CDATA[light]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Wed, 04 Apr 2018 20:19:34 GMT</pubDate>
            <atom:updated>2018-04-04T20:19:34.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_pPproWBPHCYkJx1i487Q.jpeg" /></figure><p>This was clicked in 2014 during Diwali, the festival of light.</p><p>There is something soothing about these traditional clay lamps. Even though they are hot when you try to touch, they tend to make anyone calm on staring at them.</p><p>But again it all depends on the person looking at them. Someone has written it so beautifully,</p><p><em>We all are stars</em></p><p><em>wrapped in skin</em></p><p><em>The light you are looking for</em></p><p><em>has always been within!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46a431c933f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/light-46a431c933f3">Light</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Independence]]></title>
            <link>https://medium.com/ameykpatil/independence-9fc75657df88?source=rss-df4c80a03c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fc75657df88</guid>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[scribbles]]></category>
            <category><![CDATA[ameykpatil]]></category>
            <category><![CDATA[independence]]></category>
            <category><![CDATA[short-tale]]></category>
            <dc:creator><![CDATA[Amey Patil]]></dc:creator>
            <pubDate>Sun, 01 Apr 2018 20:41:36 GMT</pubDate>
            <atom:updated>2018-04-01T21:02:01.896Z</atom:updated>
            <content:encoded><![CDATA[<p><em>At the stroke of the midnight hour,</em></p><p><em>When the world sleeps,</em></p><p><em>A part of me awakes to life &amp; freedom,</em></p><p><em>…and starts coding!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPEOhCTHYNhoV3LQ3cobHg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@vheath">Victoria Heath</a> on Unsplash</figcaption></figure><p>If you don’t already know then let me tell you, these are the lines from the very popular speech of Mr. Nehru, the first prime minister of India. This was delivered when India got the independence from Britishers who ruled India for more than 150 years. The lines were tweaked to show the secret life of programmers who prefer to code at night. When you are passionate about something, a freedom to follow your passion is the only thing that your life keeps searching every now and then.</p><p><a href="https://www.instagram.com/p/BJF0bQMAJwx"><em>*This short-tale was originally published by me on Instagram on Independence Day of India.</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fc75657df88" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ameykpatil/independence-9fc75657df88">Independence</a> was originally published in <a href="https://medium.com/ameykpatil">ameykpatil</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>