Skip to content
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

Add attachments retrieval #95

Open
Frank995 opened this issue Nov 7, 2023 · 9 comments
Open

Add attachments retrieval #95

Frank995 opened this issue Nov 7, 2023 · 9 comments

Comments

@Frank995
Copy link

Frank995 commented Nov 7, 2023

Hi all.

Just started working with this library and I noticed that there is no functionality to retrieve attachments from posts, or upload one. Is it on the roadmap?

@bennylope
Copy link
Collaborator

It could be! Interested in contributing it?

@Frank995
Copy link
Author

Frank995 commented Nov 9, 2023

Yes I would. Currently I'm using a dirty regex to get the attachment url form the post HTML an then send the request manually by callig "_get". Would you have any advice or a reference for how to retrieve them more cleanly?

@bennylope
Copy link
Collaborator

Would you have any advice or a reference for how to retrieve them more cleanly?

No idea!

And there doesn't seem to be any support for this in the official Ruby API client.

That being said, I'd be less shy about using regex. The Discourse app itself uses a CSS selector to identify attachments from posts!

https://github.com/discourse/discourse/blob/d91456fd53c4bb462058ecdd676e980c6b2a1dd6/app/models/post_analyzer.rb#L73

A method returning a list of attachments from an individual post sounds useful; wouldn't worry too much if it uses regex if it works.

@goetzk
Copy link
Collaborator

goetzk commented Nov 10, 2023

There are several ways to upload files documented in the API docs (https://docs.discourse.org/#tag/Uploadshttps://docs.discourse.org/#tag/Uploads) but I don't see anything about specifically listing uploads. Weird!

I searched for a while on https://meta.discourse.org/ and didn't find anything there either, so it really looks like pulling data out via regex is the "supported" way.

@Frank995
Copy link
Author

Got it, that's very weird. I'm working on it!

@Frank995
Copy link
Author

I wanted to push a branch but I got permission denied

@goetzk
Copy link
Collaborator

goetzk commented Nov 10, 2023

I wanted to push a branch but I got permission denied

You need to use the "fork" button on GitHub to create a copy then clone that copy to your computer.
On mobile so can't look up the docs, hopefully that gets you started.

@Frank995
Copy link
Author

I did push one, open to review and suggestions

@goetzk
Copy link
Collaborator

goetzk commented Nov 15, 2023

I've added a review - thanks for your submission!

Frank995 added a commit to Frank995/pydiscourse that referenced this issue Nov 29, 2023
Frank995 added a commit to Frank995/pydiscourse that referenced this issue Nov 29, 2023
Frank995 added a commit to Frank995/pydiscourse that referenced this issue Nov 29, 2023
Frank995 added a commit to Frank995/pydiscourse that referenced this issue Jan 2, 2024
Frank995 added a commit to Frank995/pydiscourse that referenced this issue Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants