Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check_duplicates and save_duplicates parameters to upload_from_url[_sync] #240

Merged
merged 2 commits into from
Jun 23, 2023

Conversation

evgkirov
Copy link
Collaborator

@evgkirov evgkirov commented Jun 1, 2023

Support for check_URL_duplicates and save_URL_duplicates API parameters has been added when calling Uploadcare.upload_from_url or Uploadcare.upload_from_url_sync.

API: https://uploadcare.com/api-refs/upload-api/#tag/Upload/operation/fromURLUpload

Addresses #239

Usage example:

from pyuploadcare import Uploadcare

uploadcare = Uploadcare(public_key="YOUR_PUBLIC_KEY", secret_key="YOUR_SECRET_KEY")

# Raises FileAlreadyUploaded if duplicate (as we can't return FileFromUrl without a token).
# Returns FileFromUrl instance if not.
file_from_url = uploadcare.upload_from_url("https://source.unsplash.com/random", check_duplicates=True) 

# Always returns File instance (if upload is a duplicate it returns the old one).
file = uploadcare.upload_from_url_sync("https://source.unsplash.com/random", check_duplicates=True) 
  • Should the universal Uploadcare.upload method have this feature as well? On one hand, it makes sense, but on the other hand, I didn't want it to become bloated.

pyuploadcare/exceptions.py Outdated Show resolved Hide resolved
Copy link
Member

@rsedykh rsedykh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you bump up the version, and add this to the changelog?

pyuploadcare/api/api.py Show resolved Hide resolved
@evgkirov evgkirov force-pushed the feature/239-check_URL_duplicates branch from 400adcf to e8fdd98 Compare June 23, 2023 15:38
@evgkirov evgkirov merged commit e8fdd98 into main Jun 23, 2023
5 of 6 checks passed
evgkirov added a commit that referenced this pull request Jun 23, 2023
evgkirov added a commit that referenced this pull request Jun 23, 2023
evgkirov added a commit that referenced this pull request Jun 23, 2023
Fix flake8 warnings (after #239 #240) and update HISTORY.md
@evgkirov evgkirov deleted the feature/239-check_URL_duplicates branch November 13, 2023 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants