-
Notifications
You must be signed in to change notification settings - Fork 247
Fix upload photo #296
base: master
Are you sure you want to change the base?
Fix upload photo #296
Conversation
Hi, I have applied goinsta like format and added uploadPhoto as a method to media. |
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 |
Hey, |
w.WriteField("is_sidecar", toString(1)) | ||
} | ||
fw, err := w.CreateFormFile("photo", photoName) | ||
rndNumber := rand.Intn(9999999999-1000000000) + 1000000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this is needed?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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 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