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

Port missing in URL for "send notification" via web gui / attachement #726

Closed
un99known99 opened this issue May 13, 2023 · 12 comments · Fixed by #728
Closed

Port missing in URL for "send notification" via web gui / attachement #726

un99known99 opened this issue May 13, 2023 · 12 comments · Fixed by #728
Labels
🪲 bug Something isn't working

Comments

@un99known99
Copy link

un99known99 commented May 13, 2023

Port missing in URL for "send notification" via web gui / attachement see screenshot:

grafik

grafik

should look like https://ntfy.example.org:9999/file/Xx7CQB4e8c25.exe, right?

BTW: is it intended that file name in link is not reflecting original filename?

@un99known99 un99known99 added the 🪲 bug Something isn't working label May 13, 2023
@wunter8
Copy link
Contributor

wunter8 commented May 14, 2023

Do you have the port included in the base-url setting in server.yml?

Also, yes, the filename will be different. It generates a random ID to prevent anyone from guessing the URL since it isn't protected by access controls. If you want the filename to be something else when you download it, you can include the Filename header

@un99known99
Copy link
Author

un99known99 commented May 14, 2023

Hi, thx, correct, stupied me, didnt include URL PORT. For the clear filename I checked Server.yml but didnt find the parameter for getting Real name, can u guide me to the correct parameter name?

Talking about sending test files in webgui, there is no option or possibility to set Real filename

Thx in advance

@wunter8
Copy link
Contributor

wunter8 commented May 14, 2023

You need to include the Filename header with each message you send. See https://docs.ntfy.sh/publish/#attach-local-file

I'm pretty sure the web app automatically adds the Filename header. The attachment link will still include a random ID, but when you download the file, its name should be correct.

@un99known99
Copy link
Author

un99known99 commented May 14, 2023

ah, ok, but via the "testing" it seems not to be possible:

grafik

grafik

so, seems only a CLI thing working with real filenames then ..?

@wunter8
Copy link
Contributor

wunter8 commented May 14, 2023

Did you try downloading the file? It should have the correct filename after it's downloaded even though the download URL has the random ID

@un99known99
Copy link
Author

nope, not working:

grafik

@wunter8
Copy link
Contributor

wunter8 commented May 14, 2023

How did you send the notification with the attachment?

@un99known99
Copy link
Author

un99known99 commented May 14, 2023

yepp, attache local file

grafik

@wunter8
Copy link
Contributor

wunter8 commented May 14, 2023

I'm sorry. You are correct. I was testing it from the Android app, not the web app. In the Android app, including the Filename header in the request (which the web app does) makes the downloaded file have the correct name. But when you download the file in the browser/using the web app, the downloaded file does not have the correct name (whether or not the Filename header was included)

@un99known99
Copy link
Author

un99known99 commented May 14, 2023

no worries, I still love the tool, thx for your support - would that be worth an enhancement request???? :)

@wunter8
Copy link
Contributor

wunter8 commented May 14, 2023

@binwiederhier What do you think about adding this so that when you click "Open attachment" in the web UI it will automatically download the file with the correct filename? I just tested it locally, and it seems to work.

diff --git a/server/server.go b/server/server.go
index c0ebc6e..fbf82eb 100644
--- a/server/server.go
+++ b/server/server.go
@@ -642,6 +642,10 @@ func (s *Server) handleFile(w http.ResponseWriter, r *http.Request, v *visitor)
                return err
        }
        defer f.Close()
+       if m.Attachment.Name != "" {
+               w.Header().Set("Content-Disposition", "attachment; filename="+strconv.Quote(m.Attachment.Name))
+       }
        _, err = io.Copy(util.NewContentTypeWriter(w, r.URL.Path), f)
        return err
 }

@binwiederhier
Copy link
Owner

Sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants