Skip to content

Commit

Permalink
Merge branch 'main' into docs-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rsedykh committed Feb 9, 2024
2 parents ffd06de + 91aac73 commit 8345662
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a
Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.0.1](https://github.com/uploadcare/pyuploadcare/compare/v5.0.0...v5.0.1) - unreleased

### Fixed

- The SSL context is now cached by default, resulting in significant performance improvements when initializing the `Uploadcare` class frequently. [#279](https://github.com/uploadcare/pyuploadcare/issues/279)

## [5.0.0](https://github.com/uploadcare/pyuploadcare/compare/v4.3.0...v5.0.0) - 2023-12-28

In version 5.0, we introduce a new [file uploader](https://uploadcare.com/docs/file-uploader/), which is now the default for Django projects. If you prefer to continue using the old jQuery-based widget, you can enable it by setting the `use_legacy_widget` option in your configuration:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 Uploadcare, Inc
Copyright (c) 2024 Uploadcare, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

# General information about the project.
project = "PyUploadcare"
copyright = "2011-2023, Uploadcare Inc"
copyright = "2011-2024, Uploadcare Inc"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
16 changes: 14 additions & 2 deletions pyuploadcare/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import socket
import ssl
from time import time
from typing import (
IO,
Expand Down Expand Up @@ -41,6 +42,9 @@
from pyuploadcare.secure_url import BaseSecureUrlBuilder


DEFAULT_SSL_CONTEXT = ssl.create_default_context()


class Uploadcare:
"""Uploadcare client.
Expand Down Expand Up @@ -122,7 +126,11 @@ def __init__(
self.rest_client = Client(
base_url=api_base,
auth=auth,
verify=verify_api_ssl,
verify=(
DEFAULT_SSL_CONTEXT
if verify_api_ssl is True
else verify_api_ssl
),
timeout=timeout,
user_agent_extension=user_agent_extension,
retry_throttled=retry_throttled,
Expand All @@ -131,7 +139,11 @@ def __init__(

self.upload_client = Client(
base_url=upload_base,
verify=verify_upload_ssl,
verify=(
DEFAULT_SSL_CONTEXT
if verify_upload_ssl is True
else verify_upload_ssl
),
timeout=timeout,
user_agent_extension=user_agent_extension,
retry_throttled=retry_throttled,
Expand Down
13 changes: 6 additions & 7 deletions tests/integration/test_api_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
# increase throttle retries for Travis CI
conf.retry_throttled = 10

IMAGE_URL = (
"https://github.githubassets.com/images/modules/logos_page/Octocat.png"
)
IMAGE_URL = "https://octodex.github.com/images/original.png"
IMAGE_FILENAME = "original.png"

ASSETS_PATH = Path(__file__).parent / "assets"
IMAGE_PATH = ASSETS_PATH / "img.png"
Expand Down Expand Up @@ -106,15 +105,15 @@ def test_successful_upload_from_url(uploadcare):
def test_successful_upload_from_url_sync_autostore(uploadcare):
file = uploadcare.upload_from_url_sync(IMAGE_URL, interval=1)
assert isinstance(file, File)
assert file.filename == "Octocat.png"
assert file.filename == IMAGE_FILENAME
assert file.datetime_stored is not None
assert isinstance(file.datetime_stored, datetime)


def test_successful_upload_by_url(uploadcare):
file = uploadcare.upload(IMAGE_URL)
assert isinstance(file, File)
assert file.filename == "Octocat.png"
assert file.filename == IMAGE_FILENAME


def test_successful_upload_from_url_signed(uploadcare):
Expand Down Expand Up @@ -148,15 +147,15 @@ def test_successful_upload_from_url_check_duplicates(uploadcare):
def test_successful_upload_from_url_sync_autostore_signed(uploadcare):
file = uploadcare.upload_from_url_sync(IMAGE_URL, interval=1)
assert isinstance(file, File)
assert file.filename == "Octocat.png"
assert file.filename == IMAGE_FILENAME
assert file.datetime_stored is not None
assert isinstance(file.datetime_stored, datetime)


def test_successful_upload_from_url_sync_dont_store(uploadcare):
file = uploadcare.upload_from_url_sync(IMAGE_URL, store=False, interval=1)
assert isinstance(file, File)
assert file.filename == "Octocat.png"
assert file.filename == IMAGE_FILENAME
assert file.datetime_stored is None


Expand Down

0 comments on commit 8345662

Please sign in to comment.