ConfluencePS icon indicating copy to clipboard operation
ConfluencePS copied to clipboard

Add-ConfluenceAttachment hangs on files over 2MB

Open jobafett2012 opened this issue 6 years ago • 8 comments

When attempting to upload any files larger than 2MB (2-7MB in our case) to a page in our Confluence space, powershell's memory usage on the client machine doing the uploading spikes to 2-3GB and the upload never completes. We can upload files less than 2MB quickly and without issue, and we have confirmed with our Atlassian team that the max file size for REST API uploads is 10MB. We are on the latest version of AtlassianPS and our server is on Confluence version 6.13.4

jobafett2012 avatar May 20 '19 17:05 jobafett2012

I am sorry, but I couldn't reproduce your problem. I tried 3 different files, as you will see below:

Add-ConfluenceAttachment -PageID $page.id -FilePath $largeFile
ID        : 265846790
Status    : current
Title     : latest_usb_driver_windows.zip
Filename  : 215187457_latest_usb_driver_windows.zip
MediaType : application/zip
FileSize  : 8682859
Comment   : 
SpaceKey  : RD
PageID    : 215187457
Version   : 1
URL       : https://powershell.atlassian.net/wiki/download/attachments/215187457/latest_usb_driver_windows.zip?version=1&modificationDate=1559655792966&cacheVersion=1&api=v2
Get-ConfluenceAttachment -PageID $page.id | select title,filesize      
Title                         FileSize
-----                         --------
latest_usb_driver_windows.zip  8682859
LexaPrinterOne_1.10.bin        1036736
favicon_package_v0.16.zip        54456

what version of the module are you using? what version of confluence are you using?

lipkau avatar Jun 04 '19 13:06 lipkau

Confluence Version: 6.13.4 AtlassianPS/ConfluencePS Version: 2.5

jobafett2012 avatar Jun 06 '19 19:06 jobafett2012

I did some testing and for every 1MB your uploaded file is, the PowerShell process' memory usage increases by ~1,600MB.

Confluence Cloud 1000.0.0-52f4e0df752 ConfluencePS Version: 2.5

ConfluencePS_i170_tests.txt

JoshCrook avatar Jul 03 '19 16:07 JoshCrook

I did some testing and for every 1MB your uploaded file is, the PowerShell process' memory usage increases by ~1,600MB.

Confluence Cloud 1000.0.0-52f4e0df752 ConfluencePS Version: 2.5

ConfluencePS_i170_tests.txt

This is pretty similar to the behavior we experience. I assume there hasn't been any progress on finding and possibly correcting this?

jobafett2012 avatar Sep 13 '19 03:09 jobafett2012

Sorry, no. I didn't have had time to look into this yet

lipkau avatar Sep 13 '19 12:09 lipkau

Also seeing this on: Confluence 6.10.1 ConfluencePS 2.5

spudsrus avatar Sep 23 '19 01:09 spudsrus

Not sure if the issue is with the module or the confluence rest API. I've been able to work around the issue by using a webclient upload method that I guessed would work from seeing it on a jira thread.

$Headers = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($credential.UserName+":"+[System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($credential.Password)) )))} 

$wc = new-object System.Net.WebClient
$wc.Headers.Add("Authorization", $headers.Authorization)
$wc.Headers.Add("X-Atlassian-Token", "nocheck") 
$wc.UploadFile("<site>/rest/api/content/<pageid>/child/attachment/", $filepath)

spudsrus avatar Sep 24 '19 03:09 spudsrus

I have this same issue. spudrus's workaround works for me.

ConfluencePS 2.5 PSVersion 5.1.18362.145

Name : Visual Studio Code Host Version : 2019.9.0

Confluence Cloud Confluence 1000.0.0

SamWalkerRxSense avatar Nov 04 '19 16:11 SamWalkerRxSense