uploadcare-ruby 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/CHANGELOG.md +8 -0
  4. data/README.md +19 -5
  5. data/api_examples/rest_api/delete_files_storage.rb +6 -0
  6. data/api_examples/rest_api/delete_files_uuid_metadata_key.rb +5 -0
  7. data/api_examples/rest_api/delete_files_uuid_storage.rb +5 -0
  8. data/api_examples/rest_api/delete_groups_uuid.rb +5 -0
  9. data/api_examples/rest_api/delete_webhooks_unsubscribe.rb +5 -0
  10. data/api_examples/rest_api/get_addons_aws_rekognition_detect_labels_execute_status.rb +7 -0
  11. data/api_examples/rest_api/get_addons_aws_rekognition_detect_moderation_labels_execute_status.rb +7 -0
  12. data/api_examples/rest_api/get_addons_remove_bg_execute_status.rb +7 -0
  13. data/api_examples/rest_api/get_addons_uc_clamav_virus_scan_execute_status.rb +7 -0
  14. data/api_examples/rest_api/get_convert_document_status_token.rb +6 -0
  15. data/api_examples/rest_api/get_convert_document_uuid.rb +6 -0
  16. data/api_examples/rest_api/get_convert_video_status_token.rb +6 -0
  17. data/api_examples/rest_api/get_files.rb +6 -0
  18. data/api_examples/rest_api/get_files_uuid.rb +6 -0
  19. data/api_examples/rest_api/get_files_uuid_metadata.rb +6 -0
  20. data/api_examples/rest_api/get_files_uuid_metadata_key.rb +6 -0
  21. data/api_examples/rest_api/get_groups.rb +6 -0
  22. data/api_examples/rest_api/get_groups_uuid.rb +6 -0
  23. data/api_examples/rest_api/get_project.rb +6 -0
  24. data/api_examples/rest_api/get_webhooks.rb +6 -0
  25. data/api_examples/rest_api/post_addons_aws_rekognition_detect_labels_execute.rb +6 -0
  26. data/api_examples/rest_api/post_addons_aws_rekognition_detect_moderation_labels_execute.rb +6 -0
  27. data/api_examples/rest_api/post_addons_remove_bg_execute.rb +6 -0
  28. data/api_examples/rest_api/post_addons_uc_clamav_virus_scan_execute.rb +6 -0
  29. data/api_examples/rest_api/post_convert_document.rb +7 -0
  30. data/api_examples/rest_api/post_convert_video.rb +11 -0
  31. data/api_examples/rest_api/post_files_local_copy.rb +7 -0
  32. data/api_examples/rest_api/post_files_remote_copy.rb +8 -0
  33. data/api_examples/rest_api/post_webhooks.rb +10 -0
  34. data/api_examples/rest_api/put_files_storage.rb +9 -0
  35. data/api_examples/rest_api/put_files_uuid_metadata_key.rb +8 -0
  36. data/api_examples/rest_api/put_files_uuid_storage.rb +6 -0
  37. data/api_examples/rest_api/put_webhooks_id.rb +12 -0
  38. data/api_examples/upload_api/get_from_url_status.rb +6 -0
  39. data/api_examples/upload_api/get_group_info.rb +7 -0
  40. data/api_examples/upload_api/get_info.rb +7 -0
  41. data/api_examples/upload_api/post_base.rb +6 -0
  42. data/api_examples/upload_api/post_from_url.rb +6 -0
  43. data/api_examples/upload_api/post_group.rb +9 -0
  44. data/api_examples/upload_api/post_multipart_complete.rb +8 -0
  45. data/api_examples/upload_api/post_multipart_start.rb +8 -0
  46. data/api_examples/upload_api/put_presigned_url_x.rb +8 -0
  47. data/lib/uploadcare/client/conversion/document_conversion_client.rb +4 -0
  48. data/lib/uploadcare/client/multipart_upload_client.rb +1 -1
  49. data/lib/uploadcare/entity/conversion/base_converter.rb +7 -0
  50. data/lib/uploadcare/entity/file.rb +1 -2
  51. data/lib/uploadcare/param/authentication_header.rb +2 -2
  52. data/lib/uploadcare/ruby/version.rb +1 -1
  53. metadata +44 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cd6e50f0d12bc1cd65c531fa7e5656e41149433c042aedeb5d8899425ae6e53
4
- data.tar.gz: baa9f7cc358eba65895e608073d2ad188bc68ff1b5a44b8c51e6d5b2e72fc8bb
3
+ metadata.gz: b627592459c5fd8142372876e62f4888aa9ce94139011e583b72746ed68063b7
4
+ data.tar.gz: b695ed1e4ee129f82e589470930b2b84d58fac576f0f676095c1decc56226a1f
5
5
  SHA512:
6
- metadata.gz: eab5bac3add563b090d18e7f82e2c7c852e95ff0d99530f8a3d25ec2d9eb47f1d146d38fc3dec9335af3bb9cebb74079b5fb27d3f46c7c1971d892185607df06
7
- data.tar.gz: 2edc0a691512ac31210f5fada71d7515c59ac8305c5a522e04f2f90924af313cdba4707860e8bb6d1aaeec4053cff0869f0f5f14a458d33832c57587d3ab9822
6
+ metadata.gz: f5db8bdd4c9b77826087a6cd83c578e823abb8d1d212cf283baf887b841ba7fc643f35c41df98fa473daaf4614a7f1427cdd28da16df120effedf62e357cf5bb
7
+ data.tar.gz: 8772728c7606f69d5d8166a0a928862d6fde6849b91622022d6b0ba0814a4e9e2a586acf1e35a873cc7c835c33d28e4b197df9aebb94be89af0dc74de61b509e
data/.rubocop.yml CHANGED
@@ -34,3 +34,7 @@ Style/Documentation:
34
34
 
35
35
  Style/OptionalBooleanParameter:
36
36
  AllowedMethods: ['create']
37
+
38
+ Style/FrozenStringLiteralComment:
39
+ Exclude:
40
+ - 'api_examples/**/*'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.4.2 — 2024-05-29
4
+
5
+ ### Fixed
6
+ * Fixed the `Uploadcare::File.remote_copy` method which raised an `ApiStruct::EntityError: {url} must be Hash`. Now returns a string instead of a `File` entity instance.
7
+
8
+ ### Added
9
+ * `Document Info` API added in `DocumentConverter`.
10
+
3
11
  ## 4.4.1 — 2024-04-27
4
12
 
5
13
  ### Added
data/README.md CHANGED
@@ -556,7 +556,7 @@ An `Add-On` is an application implemented by Uploadcare that accepts uploaded fi
556
556
  ##### AWS Rekognition
557
557
 
558
558
  ```ruby
559
- # Execute AWS Rekognition Add-On for a given target to detect labels in an image.
559
+ # Execute AWS Rekognition Add-On for a given target to detect labels in an image.
560
560
  # Note: Detected labels are stored in the file's appdata.
561
561
  Uploadcare::Addons.ws_rekognition_detect_labels('FILE_UUID')
562
562
 
@@ -567,7 +567,7 @@ Uploadcare::Addons.ws_rekognition_detect_labels_status('RETURNED_ID_FROM_WS_REKO
567
567
  ##### AWS Rekognition Moderation
568
568
 
569
569
  ```ruby
570
- # Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.
570
+ # Execute AWS Rekognition Moderation Add-On for a given target to detect moderation labels in an image.
571
571
  # Note: Detected moderation labels are stored in the file's appdata.
572
572
 
573
573
  Uploadcare::Addons.ws_rekognition_detect_moderation_labels('FILE_UUID')
@@ -738,6 +738,20 @@ More examples and options can be found [here](https://uploadcare.com/docs/transf
738
738
  ##### Document
739
739
 
740
740
  After each document file upload you obtain a file identifier in UUID format.
741
+
742
+ You can use file identifier to determine the document format and possible conversion formats.
743
+ ```ruby
744
+ Uploadcare::DocumentConverter.info("dc99200d-9bd6-4b43-bfa9-aa7bfaefca40")
745
+
746
+ # Response
747
+ {:error=>nil, :format=>{
748
+ :name=>"jpg",
749
+ :conversion_formats=>[
750
+ {:name=>"avif"}, {:name=>"bmp"}, {:name=>"gif"}, {:name=>"ico"}, {:name=>"pcx"}, {:name=>"pdf"}, {:name=>"png"}, {:name=>"ps"}, {:name=>"svg"}, {:name=>"tga"}, {:name=>"thumbnail"}, {:name=>"tiff"}, {:name=>"wbmp"}, {:name=>"webp"}
751
+ ]
752
+ }}
753
+ ```
754
+
741
755
  Then you can use this file identifier to convert your document to a new format:
742
756
 
743
757
  ```ruby
@@ -841,7 +855,7 @@ You can use custom domain and CDN provider to deliver files with authenticated U
841
855
  To generate authenticated URL from the library, you should choose `Uploadcare::SignedUrlGenerators::AkamaiGenerator` (or create your own generator implementation):
842
856
 
843
857
  ```ruby
844
- generator = Uploadcare::SignedUrlGenerators::AkamaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key')
858
+ generator = Uploadcare::SignedUrlGenerators::AkamaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key')
845
859
  # Optional parameters: ttl: 300, algorithm: 'sha256'
846
860
  generator.generate_url(uuid, acl = optional)
847
861
 
@@ -849,13 +863,13 @@ generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3")
849
863
  # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/~hmac=a989cae5342f17013677f5a0e6577fc5594cc4e238fb4c95eda36634eb47018b
850
864
 
851
865
  # You can pass in ACL as a second parameter to generate_url. See https://uploadcare.com/docs/security/secure-delivery/#authenticated-urls for supported acl formats
852
- generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", '/*/')
866
+ generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", '/*/')
853
867
  # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1649405263~acl=/*/~hmac=3ce1152c6af8864b36d4dc721f08ca3cf0b3a20278d7f849e82c6c930d48ccc1
854
868
 
855
869
  # Optionally you can use wildcard: true to generate a wildcard acl token
856
870
  generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3", wildcard: true)
857
871
  # https://example.com/a7d5645e-5cd7-4046-819f-a6a2933bafe3/?token=exp=1714233449~acl=/a7d5645e-5cd7-4046-819f-a6a2933bafe3/*~hmac=a568ee2a85dd90a8a8a1ef35ea0cc0ef0acb84fe81990edd3a06eacf10a52b4e
858
-
872
+
859
873
  # You can also pass in a custom ttl and algorithm to AkamaiGenerator
860
874
  generator = Uploadcare::SignedUrlGenerators::AkamaiGenerator.new(cdn_host: 'example.com', secret_key: 'secret_key', ttl: 10)
861
875
  generator.generate_url("a7d5645e-5cd7-4046-819f-a6a2933bafe3")
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuids = %w[21975c81-7f57-4c7a-aef9-acfe28779f78 cbaf2d73-5169-4b2b-a543-496cf2813dff]
6
+ puts Uploadcare::FileList.batch_delete(uuids)
@@ -0,0 +1,5 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ puts Uploadcare::FileMetadata.delete('1bac376c-aa7e-4356-861b-dd2657b5bfd2', 'pet')
@@ -0,0 +1,5 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ puts Uploadcare::File.delete('1bac376c-aa7e-4356-861b-dd2657b5bfd2')
@@ -0,0 +1,5 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ puts Uploadcare::Group.delete('c5bec8c7-d4b6-4921-9e55-6edb027546bc~1')
@@ -0,0 +1,5 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ puts Uploadcare::Webhook.delete('https://yourwebhook.com')
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ request_id = 'd1fb31c6-ed34-4e21-bdc3-4f1485f58e21'
6
+ result = Uploadcare::Addons.ws_rekognition_detect_labels_status(request_id)
7
+ puts result.status
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ request_id = 'd1fb31c6-ed34-4e21-bdc3-4f1485f58e21'
6
+ result = Uploadcare::Addons.ws_rekognition_detect_moderation_labels_status(request_id)
7
+ puts result.status
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ request_id = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ result = Uploadcare::Addons.remove_bg_status(request_id)
7
+ puts result.status
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ request_id = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ result = Uploadcare::Addons.uc_clamav_virus_scan_status(request_id)
7
+ puts result.status
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ token = 32_921_143
6
+ puts Uploadcare::DocumentConverter.status(token)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '740e1b8c-1ad8-4324-b7ec-112c79d8eac2'
6
+ puts Uploadcare::DocumentConverter.info(uuid)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ token = 1_201_016_744
6
+ puts Uploadcare::VideoConverter.status(token)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ list = Uploadcare::FileList.file_list(stored: true, removed: false, limit: 100)
6
+ list.each { |file| puts file.inspect }
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ puts Uploadcare::File.info(uuid).inspect
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ puts Uploadcare::FileMetadata.show(uuid, 'pet')
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ puts Uploadcare::FileMetadata.index(uuid).inspect
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ groups = Uploadcare::GroupList.list(limit: 10)
6
+ groups.each { |group| puts group.inspect }
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = 'c5bec8c7-d4b6-4921-9e55-6edb027546bc~1'
6
+ puts Uploadcare::Group.info(uuid).inspect
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ project_info = Uploadcare::Project.show
6
+ puts project_info.inspect
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ webhooks = Uploadcare::Webhook.list
6
+ webhooks.each { |webhook| puts webhook.inspect }
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ Uploadcare::Addons.ws_rekognition_detect_labels(uuid)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ Uploadcare::Addons.ws_rekognition_detect_moderation_labels(uuid)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ Uploadcare::Addons.remove_bg(uuid, crop: true)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ Uploadcare::Addons.uc_clamav_virus_scan(uuid, purge_infected: true)
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ document_params = { uuid: '1bac376c-aa7e-4356-861b-dd2657b5bfd2', format: :pdf }
6
+ options = { store: true }
7
+ Uploadcare::DocumentConverter.convert(document_params, options)
@@ -0,0 +1,11 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ video_params = {
6
+ uuid: '1bac376c-aa7e-4356-861b-dd2657b5bfd2',
7
+ format: :mp4,
8
+ quality: :lighter
9
+ }
10
+ options = { store: true }
11
+ Uploadcare::VideoConverter.convert(video_params, options)
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ source = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ copied_file = Uploadcare::File.local_copy(source, store: true)
7
+ puts copied_file.uuid
@@ -0,0 +1,8 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ source_object = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ target = 'custom_storage_connected_to_the_project'
7
+ copied_file_url = Uploadcare::File.remote_copy(source_object, target, make_public: true)
8
+ puts copied_file_url
@@ -0,0 +1,10 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ options = {
6
+ target_url: 'https://yourwebhook.com',
7
+ event: 'file.uploaded',
8
+ is_active: true
9
+ }
10
+ Uploadcare::Webhook.create(**options)
@@ -0,0 +1,9 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuids = %w[
6
+ b7a301d1-1bd0-473d-8d32-708dd55addc0
7
+ 1bac376c-aa7e-4356-861b-dd2657b5bfd2
8
+ ]
9
+ Uploadcare::FileList.batch_store(uuids)
@@ -0,0 +1,8 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ key = 'pet'
7
+ value = 'dog'
8
+ Uploadcare::FileMetadata.update(uuid, key, value)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '1bac376c-aa7e-4356-861b-dd2657b5bfd2'
6
+ Uploadcare::File.store(uuid)
@@ -0,0 +1,12 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ webhook_id = 1_473_151
6
+ options = {
7
+ target_url: 'https://yourwebhook.com',
8
+ event: 'file.uploaded',
9
+ is_active: true,
10
+ signing_secret: 'webhook-secret'
11
+ }
12
+ Uploadcare::Webhook.update(webhook_id, options)
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ token = '945ebb27-1fd6-46c6-a859-b9893712d650'
6
+ puts Uploadcare::Uploader.get_upload_from_url_status(token)
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '0d712319-b970-4602-850c-bae1ced521a6~1'
6
+ info = Uploadcare::Group.info(uuid)
7
+ puts info.inspect
@@ -0,0 +1,7 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuid = '740e1b8c-1ad8-4324-b7ec-112c79d8eac2'
6
+ info = Uploadcare::File.info(uuid)
7
+ puts info.inspect
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ source_file = File.open('image.png')
6
+ Uploadcare::Uploader.upload(source_file, store: 'auto')
@@ -0,0 +1,6 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ source_url = 'https://source.unsplash.com/featured'
6
+ Uploadcare::Uploader.upload(source_url, store: 'auto')
@@ -0,0 +1,9 @@
1
+ require 'uploadcare'
2
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
3
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
4
+
5
+ uuids = [
6
+ 'd6d34fa9-addd-472c-868d-2e5c105f9fcd',
7
+ 'b1026315-8116-4632-8364-607e64fca723/-/resize/x800/'
8
+ ]
9
+ Uploadcare::Group.create(uuids)
@@ -0,0 +1,8 @@
1
+ # Uploadcare lib provides high level API for multipart uploads that does everything for you
2
+
3
+ require 'uploadcare'
4
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
5
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
6
+
7
+ source_file = File.open('image.png')
8
+ Uploadcare::Uploader.upload(source_file, store: 'auto')
@@ -0,0 +1,8 @@
1
+ # Uploadcare lib provides high level API for multipart uploads that does everything for you
2
+
3
+ require 'uploadcare'
4
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
5
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
6
+
7
+ source_file = File.open('image.png')
8
+ Uploadcare::Uploader.upload(source_file, store: 'auto')
@@ -0,0 +1,8 @@
1
+ # Uploadcare lib provides high level API for multipart uploads that does everything for you
2
+
3
+ require 'uploadcare'
4
+ Uploadcare.config.public_key = 'YOUR_PUBLIC_KEY'
5
+ Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'
6
+
7
+ source_file = File.open('image.png')
8
+ Uploadcare::Uploader.upload(source_file, store: 'auto')
@@ -22,6 +22,10 @@ module Uploadcare
22
22
  get(uri: "/convert/document/status/#{token}/")
23
23
  end
24
24
 
25
+ def document_info(uuid)
26
+ get(uri: "/convert/document/#{uuid}/")
27
+ end
28
+
25
29
  private
26
30
 
27
31
  def convert_uri
@@ -47,7 +47,7 @@ module Uploadcare
47
47
  private
48
48
 
49
49
  def form_data_for(file)
50
- form_data_file = super(file)
50
+ form_data_file = super
51
51
  {
52
52
  filename: form_data_file.filename,
53
53
  size: form_data_file.size,
@@ -23,6 +23,13 @@ module Uploadcare
23
23
  conversion_client.new.get_conversion_status(token)
24
24
  end
25
25
 
26
+ # Returns the document format and possible conversion formats.
27
+ #
28
+ # @param uuid [String] UUID of the document
29
+ def info(uuid)
30
+ conversion_client.new.document_info(uuid)
31
+ end
32
+
26
33
  private
27
34
 
28
35
  def conversion_client
@@ -64,8 +64,7 @@ module Uploadcare
64
64
  #
65
65
  # @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File/operation/createRemoteCopy
66
66
  def self.remote_copy(source, target, args = {})
67
- response = FileClient.new.remote_copy(source: source, target: target, **args).success[:result]
68
- File.new(response)
67
+ FileClient.new.remote_copy(source: source, target: target, **args).success[:result]
69
68
  end
70
69
 
71
70
  # Instance version of {internal_copy}
@@ -23,8 +23,8 @@ module Uploadcare
23
23
  end
24
24
 
25
25
  def self.validate_auth_config
26
- raise AuthError, 'Public Key is blank.' if is_blank?(Uploadcare.config.public_key)
27
- raise AuthError, 'Secret Key is blank.' if is_blank?(Uploadcare.config.secret_key)
26
+ raise Uploadcare::Exception::AuthError, 'Public Key is blank.' if is_blank?(Uploadcare.config.public_key)
27
+ raise Uploadcare::Exception::AuthError, 'Secret Key is blank.' if is_blank?(Uploadcare.config.secret_key)
28
28
  end
29
29
 
30
30
  # rubocop:disable Naming/PredicateName
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uploadcare
4
- VERSION = '4.4.1'
4
+ VERSION = '4.4.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadcare-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@dmitrijivanchenko (Dmitrij Ivanchenko), @T0mbery (Andrey Aksenov)"
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-04-28 00:00:00.000000000 Z
12
+ date: 2024-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mimemagic
@@ -93,6 +93,48 @@ files:
93
93
  - LICENSE
94
94
  - README.md
95
95
  - Rakefile
96
+ - api_examples/rest_api/delete_files_storage.rb
97
+ - api_examples/rest_api/delete_files_uuid_metadata_key.rb
98
+ - api_examples/rest_api/delete_files_uuid_storage.rb
99
+ - api_examples/rest_api/delete_groups_uuid.rb
100
+ - api_examples/rest_api/delete_webhooks_unsubscribe.rb
101
+ - api_examples/rest_api/get_addons_aws_rekognition_detect_labels_execute_status.rb
102
+ - api_examples/rest_api/get_addons_aws_rekognition_detect_moderation_labels_execute_status.rb
103
+ - api_examples/rest_api/get_addons_remove_bg_execute_status.rb
104
+ - api_examples/rest_api/get_addons_uc_clamav_virus_scan_execute_status.rb
105
+ - api_examples/rest_api/get_convert_document_status_token.rb
106
+ - api_examples/rest_api/get_convert_document_uuid.rb
107
+ - api_examples/rest_api/get_convert_video_status_token.rb
108
+ - api_examples/rest_api/get_files.rb
109
+ - api_examples/rest_api/get_files_uuid.rb
110
+ - api_examples/rest_api/get_files_uuid_metadata.rb
111
+ - api_examples/rest_api/get_files_uuid_metadata_key.rb
112
+ - api_examples/rest_api/get_groups.rb
113
+ - api_examples/rest_api/get_groups_uuid.rb
114
+ - api_examples/rest_api/get_project.rb
115
+ - api_examples/rest_api/get_webhooks.rb
116
+ - api_examples/rest_api/post_addons_aws_rekognition_detect_labels_execute.rb
117
+ - api_examples/rest_api/post_addons_aws_rekognition_detect_moderation_labels_execute.rb
118
+ - api_examples/rest_api/post_addons_remove_bg_execute.rb
119
+ - api_examples/rest_api/post_addons_uc_clamav_virus_scan_execute.rb
120
+ - api_examples/rest_api/post_convert_document.rb
121
+ - api_examples/rest_api/post_convert_video.rb
122
+ - api_examples/rest_api/post_files_local_copy.rb
123
+ - api_examples/rest_api/post_files_remote_copy.rb
124
+ - api_examples/rest_api/post_webhooks.rb
125
+ - api_examples/rest_api/put_files_storage.rb
126
+ - api_examples/rest_api/put_files_uuid_metadata_key.rb
127
+ - api_examples/rest_api/put_files_uuid_storage.rb
128
+ - api_examples/rest_api/put_webhooks_id.rb
129
+ - api_examples/upload_api/get_from_url_status.rb
130
+ - api_examples/upload_api/get_group_info.rb
131
+ - api_examples/upload_api/get_info.rb
132
+ - api_examples/upload_api/post_base.rb
133
+ - api_examples/upload_api/post_from_url.rb
134
+ - api_examples/upload_api/post_group.rb
135
+ - api_examples/upload_api/post_multipart_complete.rb
136
+ - api_examples/upload_api/post_multipart_start.rb
137
+ - api_examples/upload_api/put_presigned_url_x.rb
96
138
  - bin/console
97
139
  - bin/setup
98
140
  - lib/uploadcare.rb