Comments (5)
Could you provide more details? Which confluence version are you using (DC or cloud, if DC which build version, are you using any reverse proxy?). And what is your host on which you are trying to save the files (OS type, version). Also go to the directory where attachments should be saved. What's the size of each file?
I just checked on Confluence cloud + macOS 14.2.1 and I haven't encountered any problems.
from atlassian-python-api.
Hi gkowalc
Thank you for your reply.
Confluence:
Version (DC or cloud) → Datacenter 7.19.18
Build Number → 8804
Build Date → 16.01.2024
Reverse Proxy: yes
Host: redhat/ubi8:8.9-1107 and it runs as a docker container
Client:
The python process runs on macOS 13.6.3 (22G436) under python 3.8.10.
On the Confluence page are 4 attachments (50 kB to 1.5 MB as png or pdf). The files are available in the download directory on the Mac, but with a size of 0 bytes
With regards
Andreas
from atlassian-python-api.
Thanks for the info @git-aybo
I bootstrapped DC testing instance on AWS (ubuntu EC2 + load balancer/proxy) and I was able to get correct attachments size from downloaded sample j.pg attachment (±5mb) but not from.png and .txt attachments so your issue is (partially) reproducible. It is weird that I had no issue with .jpg file.
download_attachments_from_page function relies on following concept:
download_link = self.url + attachment["_links"]["download"] r = self._session.get(f"{download_link}") file_path = os.path.join(path, file_name) with open(file_path, "wb") as f: f.write(r.content)
Above code calls _session object which is used differently between DC and cloud (DC uses token param to authenticate whereas cloud is username + password(.
` def _create_basic_session(self, username, password):
self._session.auth = (username, password)
def _create_token_session(self, token):
self._update_header("Authorization", "Bearer {token}".format(token=token))`
I am not sure if the issue is with reply from from the confluence DC API itself or with our wrapper code rest_client.py. I am going to look closer at this bug in the upcoming week and then we can make a decision if this feature should be marked as "cloud only" of if there is some reasonable fix for download_attachments_from_page function. Ideally I would like not to make any changes to rest_client.py file.
from atlassian-python-api.
Hi gkowalc
Thank you for your work and your information. The behavior is the same for me. A JPG file can be downloaded successfully.
With regards
Andreas
from atlassian-python-api.
I'm experiencing some confusion at the moment. A few days ago, while trying to replicate a problem, I managed to successfully download jpeg files but encountered difficulties with .png and .pdf files. Today, I created a new testing instance on AWS. This setup mirrors the previous one, using version 7.19.18 on an Ubuntu EC2, with the same versions of Python and the required library. All attachments appear to be of the correct size. So could it be the problem is caused by some weird caching issue?
Can anyone attempt to reproduce the download_attachments_from_page on version 7.19.18 or the latest 8.5?
from atlassian import Confluence
import os
confluence_DC =Confluence(
url='confl_server_url',
token='<api_token>'
)
def download_attachments_test(api_wrapper_object, page_id, directory_path):
api_wrapper_object.download_attachments_from_page(page_id=page_id, path=directory_path)
def check_file_size(directory):
for filename in os.listdir(directory):
if os.path.isfile(os.path.join(directory, filename)):
print(f'File: {filename}, Size: {os.path.getsize(os.path.join(directory, filename))} bytes')
download_attachments_test(confluence_DC, dc_page, path_dc)
check_file_size(path_dc)
from atlassian-python-api.
Related Issues (20)
- unexpected keyword argument 'paging_workaround' HOT 6
- Insight (Assets) class not correctly setting self.default_headers when cloud=True HOT 1
- [Confluence] Attachments - get_attachments_from_content HOT 1
- Bad Request for pullrequests with page params HOT 1
- bitbucket.project_list() only returns generators HOT 3
- Export page not working HOT 1
- Add label parameter to get_all_spaces method HOT 2
- pylint missing from requirements-dev.txt
- Edit issue not respect documentation
- Reading large confluence page
- export_page is giving 404 error
- Grammar and URL error on get_page_id
- black formatting in multiple versions of python HOT 3
- New release HOT 2
- confluence.add_user_to_group is wrong HOT 5
- [Jira] "Agile" methods don't use the “api_root” instance attribute, as most other methods do HOT 1
- [Bug] HTTPError 415 when providing files using POST HOT 1
- Trying to match the total number of issues with the front end through the api HOT 6
- PSQLException and timeouts on removing projects
- When using JIRA api to query issue, all the fields with datetime format doesn't fit user's preference setting timezone. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atlassian-python-api.