assemblyai 1.0.0.pre.beta.5 → 1.0.0.pre.beta.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d91bff775d7a91af629545e3aebf04fd8af3757c0593c9782eff3bd6e838170
4
- data.tar.gz: 27b065dedebaab7a01389e58870f322dd7c7f7eb2e0aafac71077b73eff4833a
3
+ metadata.gz: '05358a3c10dddca139c259ed392c8488a6ba4ed4906e13f8d74e28e3d68cfebb'
4
+ data.tar.gz: 982655216a96652f2cf985de884a68a1f881f5378baebd0c99f28cd6ee6bbe67
5
5
  SHA512:
6
- metadata.gz: 82a793a096563db2d9f57be102e5076fd6a2b2a8c293cac817c83bf578f32dac03ee7ab1f05246200a9f87eafd8451eb2fb71d86aa2302e26191c6ac8bfe2634
7
- data.tar.gz: 591118e0a7fde11c070e19518e338498defda2187bd8e4d1fa0a8205c5baba910e29d64c22462c1fce4c57f969b6b9bb657c1da64f29d1e9eeb8194fb4c3f650
6
+ metadata.gz: 4b60a195c0ace12498524aa9bee83de6d8913d546797444f8774eac44c9aa92ca9651826d37215cc527f3aa4e17fbeaf09fef09375c82c8be735d62709e6823b
7
+ data.tar.gz: f5d04c938bd2ada068afb6d1347578a074aa61a9b1a5dc481abb08d594a92d0a2db6025069d584d4dd9fb9280caf99e61b9eaa4b87e11b63fd5274a24508c270
@@ -17,16 +17,39 @@ module AssemblyAI
17
17
 
18
18
  # Upload your media file directly to the AssemblyAI API if it isn't accessible via a URL already.
19
19
  #
20
- # @param request [String] Base64 encoded bytes
20
+ # @param file [String, IO] File path, Base64 String, or an IO object (e.g. Faraday::UploadIO, etc.)
21
21
  # @param request_options [RequestOptions]
22
22
  # @return [Files::UploadedFile]
23
- def upload(request:, request_options: nil)
23
+ def upload(file:, request_options: nil)
24
24
  response = @request_client.conn.post("/v2/upload") do |req|
25
+ if file.is_a? String
26
+ begin
27
+ path = Pathname.new(file)
28
+ rescue StandardError
29
+ file_data = file
30
+ end
31
+ unless path.nil?
32
+ if path.file?
33
+ file_data = File.new(file)
34
+ elsif path.directory?
35
+ raise "file path has to be a path to file, but is a path to directory"
36
+ else
37
+ raise "file at path does not exist"
38
+ end
39
+ end
40
+ else
41
+ file_data = file
42
+ end
25
43
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
26
44
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
27
45
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
28
46
  req.headers["Content-Type"] = "application/octet-stream"
29
- req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
47
+ if file.is_a? File
48
+ req.headers["Content-Length"] = File.size(file_data.path).to_s
49
+ else
50
+ req.headers["Transfer-Encoding"] = "chunked"
51
+ end
52
+ req.body = file_data
30
53
  end
31
54
  Files::UploadedFile.from_json(json_object: response.body)
32
55
  end
@@ -44,17 +67,40 @@ module AssemblyAI
44
67
 
45
68
  # Upload your media file directly to the AssemblyAI API if it isn't accessible via a URL already.
46
69
  #
47
- # @param request [String] Base64 encoded bytes
70
+ # @param file [String, IO] File path, Base64 String, or an IO object (e.g. Faraday::UploadIO, etc.)
48
71
  # @param request_options [RequestOptions]
49
72
  # @return [Files::UploadedFile]
50
- def upload(request:, request_options: nil)
73
+ def upload(file:, request_options: nil)
51
74
  Async do
52
75
  response = @request_client.conn.post("/v2/upload") do |req|
76
+ if file.is_a? String
77
+ begin
78
+ path = Pathname.new(file)
79
+ rescue StandardError
80
+ file_data = file
81
+ end
82
+ unless path.nil?
83
+ if path.file?
84
+ file_data = File.new(file)
85
+ elsif path.directory?
86
+ raise "file path has to be a path to file, but is a path to directory"
87
+ else
88
+ raise "file at path does not exist"
89
+ end
90
+ end
91
+ else
92
+ file_data = file
93
+ end
53
94
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
54
95
  req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
55
96
  req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
56
97
  req.headers["Content-Type"] = "application/octet-stream"
57
- req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
98
+ if file.is_a? File
99
+ req.headers["Content-Length"] = File.size(file_data.path).to_s
100
+ else
101
+ req.headers["Transfer-Encoding"] = "chunked"
102
+ end
103
+ req.body = file_data
58
104
  end
59
105
  Files::UploadedFile.from_json(json_object: response.body)
60
106
  end
data/lib/requests.rb CHANGED
@@ -20,7 +20,7 @@ module AssemblyAI
20
20
  @headers = {
21
21
  "X-Fern-Language": "Ruby",
22
22
  "X-Fern-SDK-Name": "assemblyai",
23
- "X-Fern-SDK-Version": "1.0.0-beta.5",
23
+ "X-Fern-SDK-Version": "1.0.0-beta.6",
24
24
  "Authorization": api_key.to_s
25
25
  }
26
26
  @conn = Faraday.new(@base_url, headers: @headers) do |faraday|
@@ -46,7 +46,7 @@ module AssemblyAI
46
46
  @headers = {
47
47
  "X-Fern-Language": "Ruby",
48
48
  "X-Fern-SDK-Name": "assemblyai",
49
- "X-Fern-SDK-Version": "1.0.0-beta.5",
49
+ "X-Fern-SDK-Version": "1.0.0-beta.6",
50
50
  "Authorization": api_key.to_s
51
51
  }
52
52
  @conn = Faraday.new(@base_url, headers: @headers) do |faraday|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assemblyai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.5
4
+ version: 1.0.0.pre.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-19 00:00:00.000000000 Z
11
+ date: 2024-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http-faraday