Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.

Conversation

@manslaughter03
Copy link

Hi,

First thanks for the works.

I start to investigate upload photo bad request #281, i need this feature and not wanting to use another libray. So i try to fix this issue.

I got inspired by https://github.com/dilame/instagram-private-api/blob/master/src/repositories/upload.repository.ts#L18.

  • I use the same endpoint /rupload_igphoto/${name} instead of /upload/photo/
  • I add some headers, like : X-Instagram-Rupload-Params, Offset, X-Entity-Length.
  • I use application/octet-stream as Content-Type
  • The same for configure request i add some value in config

I add an example: examples/upload-photo/main.go, I have to update goinsta import, for test purpose i import my repository.

If you have time to review my code and test this fix in your environment.

Thanks.

manslaughter03

@manslaughter03 manslaughter03 requested a review from ahmdrz January 25, 2020 13:35
@alidhkh
Copy link

alidhkh commented Feb 14, 2020

Hi, I have applied goinsta like format and added uploadPhoto as a method to media.
See my latest commits:

alidhkh@1cf9cce
alidhkh@6303666
alidhkh@6089bca

@manslaughter03
Copy link
Author

Hi, i think we should take an io.Reader as parameter on uploadPhoto function, we should remove postPhoto and use only uploadPhoto ? Otherwise it's good idea to add switchCookiesBetweenDomains. I'm going to commit your changes in my fork and test it.

@alidhkh
Copy link

alidhkh commented Feb 16, 2020

Hey,
uploadPhoto is not only used in uploading a new photo to feed, but also in changing profile picture, sending a new story, or sending someone a new photo message; as far as I know.
Therefore, I think it's better to have a single uploadPhoto function that accepts a file name, for a reader we have to read the file each time before passing it to uploadPhoto.

w.WriteField("is_sidecar", toString(1))
}
fw, err := w.CreateFormFile("photo", photoName)
rndNumber := rand.Intn(9999999999-1000000000) + 1000000000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add this random number to generate name of the upload (part of url) and then use as value of 'X-Entity-Name' header. I use the same range used by https://github.com/dilame/instagram-private-api/blob/master/src/repositories/upload.repository.ts#L20. When i listen instagram api call from app, the requested url for upload fit this generate string.

media.go Outdated
fw, err := w.CreateFormFile("photo", photoName)
rndNumber := rand.Intn(9999999999-1000000000) + 1000000000
name := strconv.FormatInt(uploadID, 10) + "_0_" + strconv.Itoa(rndNumber)
buf := new(bytes.Buffer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:
var buf bytes.Buffer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems buf need to be initialize to be use as a reader
./media.go:960:71: cannot use buf (type bytes.Buffer) as type io.Reader in argument to http.NewRequest

@TheForgotten69 TheForgotten69 mentioned this pull request Nov 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants