@@ -983,6 +983,7 @@ def render_attachments(self):
983
983
def upload_attachments (
984
984
self , files , message , filename , author , inline = False
985
985
):
986
+ last_uploaded_filename = None
986
987
if not has_permission ("UPLOAD" ):
987
988
abort (403 )
988
989
# attachments to commit in the second step
@@ -1000,6 +1001,7 @@ def upload_attachments(
1000
1001
os .makedirs (attachment .absdirectory , mode = 0o775 , exist_ok = True )
1001
1002
upload .save (attachment .abspath )
1002
1003
to_commit .append (attachment )
1004
+ last_uploaded_filename = fn
1003
1005
if len (to_commit ) > 0 :
1004
1006
if filename is None :
1005
1007
toastmsg = "Added attachment(s): {}." .format (
@@ -1018,12 +1020,9 @@ def upload_attachments(
1018
1020
if not inline :
1019
1021
toast (toastmsg )
1020
1022
if inline :
1021
- attachment_url = url_for (
1022
- "get_attachment" ,
1023
- pagepath = self .pagepath ,
1024
- filename = fn , # pyright: ignore
1025
- )
1026
- return jsonify (filename = attachment_url )
1023
+ if last_uploaded_filename is None :
1024
+ abort (500 )
1025
+ return jsonify (filename = f"./{ last_uploaded_filename } " )
1027
1026
return redirect (url_for ("attachments" , pagepath = self .pagepath ))
1028
1027
1029
1028
def get_attachment (self , filename , revision = None ):
0 commit comments