Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
## Content Management SDK For Python
---

## v1.1.1

#### Date: 21 May 2024

- Fixed Assets upload issue.
---

## v1.1.0

#### Date: 14 May 2024
Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @contentstack/security-admin @contentstack/sdk-admin
* @contentstack/security-admin
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ result = asset.upload(asset)
- [Content Management API Docs](https://www.contentstack.com/docs/developers/apis/content-management-api)

### The MIT License (MIT)
Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights Reserved
Copyright © 2012-2024 [Contentstack](https://www.contentstack.com/). All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion contentstack_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
__author__ = 'ishaileshmishra'
__status__ = 'debug'
__region__ = 'na'
__version__ = '1.1.0'
__version__ = '1.1.1'
__host__ = 'api.contentstack.io'
__protocol__ = 'https://'
__api_version__ = 'v3'
Expand Down
10 changes: 8 additions & 2 deletions contentstack_management/assets/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"""
import json
from ..common import Parameter
import mimetypes
import os

class Assets(Parameter):
"""
Expand Down Expand Up @@ -142,8 +144,12 @@ def upload(self, file_path):
"""

url = "assets"
Parameter.add_header(self, "Content-Type", "multipart/form-data")
files = {"asset": open(f"{file_path}",'rb')}
filename = os.path.basename(file_path)
content_type, _ = mimetypes.guess_type(file_path)
files = {
'asset[upload]': (filename, open(file_path, 'rb'), content_type)
}
self.client.headers.pop('Content-Type', None)
return self.client.post(url, headers = self.client.headers, params = self.params, files = files)

def replace(self, file_path):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
python-dotenv~=1.0.0
setuptools==68.0.0
requests~=2.31.0
requests~=2.32.0
pylint
bson>=0.5.9
requests-toolbelt>=1.0.0