Code Monkey home page Code Monkey logo

Comments (5)

gkowalc avatar gkowalc commented on July 24, 2024

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.

git-aybo avatar git-aybo commented on July 24, 2024

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.

gkowalc avatar gkowalc commented on July 24, 2024

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.

git-aybo avatar git-aybo commented on July 24, 2024

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.

gkowalc avatar gkowalc commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.