Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Paste a webpage with images into confluence and images are set as a link

ffhirata March 8, 2019

I copied (Ctrl+C) a webpage and then pasted (Ctrl+V) into Confluence page. The images is appearing, but it was set as link to the image, but I would like that it be stored in the confluence (no references to link image), because I´m migrating wiki sharepoint pages to confluence and the sources will be deleted.

The work is already done (many pages are in this state), my question is there any way to convert an image by link to image stored locally without extra efforts.

1 answer

1 vote
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 11, 2019

Hello Fernando and welcome to the Community!

As far as taking a link to an image within a page in Confluence and converting to a static image that is attached to the page, this will either need to be a manual process or scripted via the REST API.

The manual process will require a user to navigate to the page(s), click the link of the image and save the image as a file. Then navigate back to the Confluence page and editing the page while removing the link and inserting the image.

The use of the API will be a lot more extensive and possibly problematic. I would approach doing this via the API as follows:

  1. Create a script the accesses the following endpoints to get all pages to scrub their content:
    1. Cloud: GET /wiki/rest/api/content
    2. Server: GET /rest/api/content
  2. Now that you have the content of a page, you will need to scrub the storage format to find image links. You will store these image links as a variable and then use a WGET to download the image files.
  3. Once the image files are downloaded for a page, you will use these endpoints to attach the images:
    1. Cloud: PUT /wiki/rest/api/content/{id}/child/attachment
    2. Server: POST /rest/api/content/{id}/child/attachment
  4. Once your images are attached to the pages, you will need to edit the storage format of your pages to include the images where the links were located. You will use these endpoints:
    1. Cloud: PUT /wiki/rest/api/content/{id}
    2. Server: PUT /rest/api/content/{contentId}

The above method should allow you to script the process but will require extensive testing and development. The ROI on this may not make sense and it may cost less to complete this effort manually. This would need to be evaluated to see which option would be better.

I hope this proves helpful in cleaning up your imported content within Confluence along.

Regards,
Stephen Sifers

ffhirata April 2, 2019

Thanks Stephen,

I asked to the administrators about REST API, but it is not enabled. So, I have done the work manually with some automation (python + PYAHK AutoHotKey).

I copied all the images from sharepoint to a local drive.
For each confluence page, I open the source code edit mode and run the automation script. It does CTRL+A, copy to clipboard, paste to a variable, set to a list. Sweep all the list looking for the html tag of image link.
When found, change html to a attach image, and save back to the list.
Once finished, convert the list to a string, and then paste back the source code.
Leave the source code edit mode.

The images will be missing, but the script has the list of images names that should be saved in the confluence page. So manually, I added the images, and afterwards delete from the visual addition (I want only to be attached).
Save the page.

If you have better solution, let me know.

Note:
I think the support should have a prompt solution for clients that want to migrate wiki sharepoint pages to confluence wiki.

Regards,
Fernando Hirata

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events