Skip to content

Commit c261d73

Browse files
author
Gonchik Tsymzhitov
committed
Bitbucket: release related to the pullrequest class
1 parent a20bb60 commit c261d73

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

atlassian/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.0
1+
3.3.0
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# coding=utf-8
2+
"""
3+
This is example to attach file with mimetype
4+
5+
"""
6+
import logging
7+
# https://pypi.org/project/python-magic/
8+
import magic
9+
from datetime import datetime
10+
from atlassian import Confluence
11+
12+
logging.basicConfig(level=logging.DEBUG)
13+
14+
confluence = Confluence(
15+
url="http://localhost:8090",
16+
username="admin",
17+
password="admin",
18+
)
19+
20+
21+
def attach_file(page_title, file_location, file_name, mime_type, space):
22+
page_id = confluence.get_page_by_title(space=space, title=page_title).get("id") or None
23+
if page_id is None:
24+
return 1
25+
try:
26+
confluence.attach_file(filename=file_location, name=file_name,
27+
content_type=mime_type, page_id=page_id, space=space)
28+
except Exception as e:
29+
return 1
30+
return 0
31+
32+
33+
mime_type = magic.Magic(mime=True)
34+
35+
file_location_with_page = "~/test/test_file.pdf"
36+
file_name = "So excited overview of report.pdf"
37+
title = "The page with attachments"
38+
space = "TST"
39+
40+
content_type = magic.from_file(file_name, mime=True)
41+
attach_file(file_location=file_location_with_page, file_name=file_name,
42+
mime_type=content_type,
43+
page_title=title, space=space)

0 commit comments

Comments
 (0)