[GH-ISSUE #726] Port missing in URL for "send notification" via web gui / attachement #529

Closed
opened 2026-05-07 00:25:08 +02:00 by BreizhHardware · 12 comments

Originally created by @un99known99 on GitHub (May 13, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/726

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?

Originally created by @un99known99 on GitHub (May 13, 2023). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/726 Port missing in URL for "send notification" via web gui / attachement see screenshot: ![grafik](https://github.com/binwiederhier/ntfy/assets/1615207/b29d9e90-fd88-425a-b3a5-8939b7d68801) ![grafik](https://github.com/binwiederhier/ntfy/assets/1615207/cf59483a-26ff-471b-b590-aaa54fec293c) 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?
BreizhHardware 2026-05-07 00:25:08 +02:00
  • closed this issue
  • added the
    🪲 bug
    label
Author
Owner

@wunter8 commented on GitHub (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

<!-- gh-comment-id:1546795453 --> @wunter8 commented on GitHub (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
Author
Owner

@un99known99 commented on GitHub (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

<!-- gh-comment-id:1546838285 --> @un99known99 commented on GitHub (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
Author
Owner

@wunter8 commented on GitHub (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.

<!-- gh-comment-id:1546899332 --> @wunter8 commented on GitHub (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.
Author
Owner

@un99known99 commented on GitHub (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 ..?

<!-- gh-comment-id:1546911557 --> @un99known99 commented on GitHub (May 14, 2023): ah, ok, but via the "testing" it seems not to be possible: ![grafik](https://github.com/binwiederhier/ntfy/assets/1615207/aded6440-a1f0-4905-a5da-e4166ea9d070) ![grafik](https://github.com/binwiederhier/ntfy/assets/1615207/7d49f379-5de3-44de-8391-c9febf70db32) so, seems only a CLI thing working with real filenames then ..?
Author
Owner

@wunter8 commented on GitHub (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

<!-- gh-comment-id:1546915255 --> @wunter8 commented on GitHub (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
Author
Owner

@un99known99 commented on GitHub (May 14, 2023):

nope, not working:

grafik

<!-- gh-comment-id:1546921266 --> @un99known99 commented on GitHub (May 14, 2023): nope, not working: ![grafik](https://github.com/binwiederhier/ntfy/assets/1615207/473933bb-fd8a-44ed-a5f0-992cda63dcbd)
Author
Owner

@wunter8 commented on GitHub (May 14, 2023):

How did you send the notification with the attachment?

<!-- gh-comment-id:1546923048 --> @wunter8 commented on GitHub (May 14, 2023): How did you send the notification with the attachment?
Author
Owner

@un99known99 commented on GitHub (May 14, 2023):

yepp, attache local file

grafik

<!-- gh-comment-id:1546923367 --> @un99known99 commented on GitHub (May 14, 2023): yepp, attache local file ![grafik](https://github.com/binwiederhier/ntfy/assets/1615207/d1a043a0-a214-4ab2-8526-f314330ed274)
Author
Owner

@wunter8 commented on GitHub (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)

<!-- gh-comment-id:1546933776 --> @wunter8 commented on GitHub (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)
Author
Owner

@un99known99 commented on GitHub (May 14, 2023):

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

<!-- gh-comment-id:1546934359 --> @un99known99 commented on GitHub (May 14, 2023): no worries, I still love the tool, thx for your support - would that be worth an enhancement request???? :)
Author
Owner

@wunter8 commented on GitHub (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
 }
<!-- gh-comment-id:1546940977 --> @wunter8 commented on GitHub (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 } ```
Author
Owner

@binwiederhier commented on GitHub (May 14, 2023):

Sounds good to me.

<!-- gh-comment-id:1546951727 --> @binwiederhier commented on GitHub (May 14, 2023): Sounds good to me.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#529
No description provided.