diff options
| author | Robert | 2017-08-22 18:07:13 +0200 |
|---|---|---|
| committer | Robert | 2017-08-22 18:07:13 +0200 |
| commit | 038710b22ccf3dd2421ec8d07fae45ef05a47ada (patch) | |
| tree | 68c0be569ac09e87ae6151803879ca52953b4a36 /app/services | |
| parent | 61c4a303183284fc107325aeeef5ace7a3e68c0c (diff) | |
| download | chouette-core-038710b22ccf3dd2421ec8d07fae45ef05a47ada.tar.bz2 | |
Refs: 4273@5h; Still debugging zip file upload inside post to Rails api; Retry removed (but not the deadcode yet) [amend me]
Diffstat (limited to 'app/services')
| -rw-r--r-- | app/services/http_service.rb | 4 | ||||
| -rw-r--r-- | app/services/zip_service.rb | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/app/services/http_service.rb b/app/services/http_service.rb index 6cf8ef93b..d3999f293 100644 --- a/app/services/http_service.rb +++ b/app/services/http_service.rb @@ -26,13 +26,11 @@ module HTTPService extend self # params: { netex_import: {referential_id: 13, workbench_id: 1}}, # upload: {file: [StringIO.new('howdy'), 'application/zip', 'greeting']}) def post_resource(host:, path:, token: nil, params: {}, upload: nil) - Faraday.new(url: host) do |c| + result = Faraday.new(url: host) do |c| c.headers['Authorization'] = "Token token=#{token.inspect}" if token c.request :multipart c.request :url_encoded c.adapter Faraday.default_adapter - require 'pry' - binding.pry return c.post path, params end end diff --git a/app/services/zip_service.rb b/app/services/zip_service.rb index f2e7fc2ed..cab301b01 100644 --- a/app/services/zip_service.rb +++ b/app/services/zip_service.rb @@ -1,12 +1,15 @@ class ZipService + # TODO: Remove me before merge https://github.com/rubyzip/rubyzip - class Subdir < Struct.new( :name, :stream) + class Subdir < Struct.new(:name, :stream) end attr_reader :current_key, :current_output, :yielder def initialize data - @zip_data = StringIO.new(data) + @zip_data = StringIO.new(data) + @current_key = nil + @current_output = nil end def subdirs @@ -38,6 +41,7 @@ class ZipService end def write_to_current_output input_stream + # the condition below is true for directory entries return if Zip::NullInputStream == input_stream current_output.write input_stream.read end @@ -58,6 +62,7 @@ class ZipService end def entry_key entry + # last dir name File.dirname.split("/").last entry.name.split('/', -1)[-2] end end |
