I’m trying to upload attachments to a Confluence page.
I use the REST API /wiki/rest/api/content/{id}/child/attachment on this document.
I call it with curl like this.
curl -D- -v -u email:password -X PUT -H 'X-Atlassian-Token: nocheck' -F 'file=@"test.txt"' -F 'minorEdit="true"' https://site-name.atlassian.net/wiki/rest/api
/content/294682641/child/attachment
When I upload attachments via the API, the filenames on the page are broken while filenames on the attachment screen are correct.
On page
On attachment Screen
What should I do to correct it?
I assume the update to the attachment won’t show the original filename as there is now a new version. The file is probably saved with an id and that’s probably what you’re seeing here.
This feels like it’s by design.
2 Likes
Hi @takafumiohtake ,
I’ve created a sample app that can add attachments to pages, but I haven’t seen malformed attachment names. Can you see if you have the issue when you try the following:
- Install my app with the URL https://dx-page-attachment-adder.glitch.me/connect.json.
- Visit any page.
- Click the … menu at the top right.
- Click the “Add attachment to this page” menu item.
- Select the attachment.
- Click the “Add attachment to this page” link.
- Edit the page and type “/attach” and click the Attachments from the popup window.
- Observe the attachments listed.
How are you adding filenames to the page?
Regards,
Dugald
1 Like
Hi @dmorrow ,
Thank you for your reply.
I reproduced the problem with your demo app.
Could you please try this?
- Create a new page.
- Drag&Drop a file to attach it to the page.
- Publish the page.
- Click the “Add attachment to this page” menu item of your demo app.
- Select the file which has the same filename as step 2.
- Click the “Add attachment to this page” link.
- The filename on the page is broken.
Regards,
Takafumi
Hi @rwhitbeck
Thank you for your reply.
This problem only occurs when attach files via Rest API.
So, I think this is a problem of Rest API.
When I attach new file via Confluence UI, the filename is kept.
Regards,
Takafumi