0

I'm trying to learning html and javascript and i gave myself this little task, I'm logged into a Instagram and I want to make a Post request for upload an image. I analized how the upload works and tried to figure out how to accomplish the task.

For manually upload an image this steps are done:

  • click the upload button ( is a <span> not into a form)
  • the file manager popus and the user select the image
  • you are redirected to another page and the image is uploaded

Once the upload button is clicked a post reuqest is raised to https://www.instagram.com/rupload_igphoto/fb_uploader_<image_id>, in the request payload there are the image binary datas and there are some custom headers that specify the image id and other image datas.

I'm trying to find a way for do the same thing. I thought that i can add inside the html page a custom form that send a POST request to the rupload_igphoto/fb_uploader_<image_id>, in this way i can persist all the coockies and the session datas but I don't know how to change the request headers and send as request payload the Image binary datas.

If i analize the request with network dev tools i can see

Inside the request parameters:
    - request payload: "ß\µÙº¦ÙÆëºÀF·GÇ&ØËUwp8çÓ4sÚdSkðEªì®[|<§îÿ...." ( that are the binary datas of the image)

Request custom headers:
    - X-Entity-Length: 370266
    - X-Entity-Name: fb_uploader_1577544947097
    - X-Instagram-Rupload-Params    
:{"media_type":1,"upload_id":"1577544947097","upload_media_height":1080,"upload_media_width":1080}

so let's say that i create a new form node inside the isntagram window,

<form action="rupload_igphoto/fb_uploader_<image_id>" method="POST" style="z-index: 10"> 
</form>

and that i know the image binary datas, how can i add the headers to the reqeust and the binary datas to the payload?

Mat.C
  • 1,379
  • 2
  • 21
  • 43

1 Answers1

1

You cannot add headers to forms, read more.

You can use XHR to send data with JS but it's very likely that Instagram has tools to block this kind of attempt (the fact that it's not a form is probably one of them).

The reason for this is to limit the amount of uploads and avoid turning the platform into a image backup service. If they intended users to have the ability to programmatic upload, they would provide an API with credentials and stuff.

That said, if you are persistent enough you still might be able to do it, just keep in mind that you will be encountering some weird problems on your way.

rafaelcastrocouto
  • 11,781
  • 3
  • 38
  • 63