Skip to content

Commit aa3b837

Browse files
committed
Upload xml test file to azure root
1 parent 37deb39 commit aa3b837

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/tasks/xml.rake

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace :xml do
66
scope = ENV.fetch("SCOPE", "all_providers")
77
lang_param = ENV["LANGUAGE"]
88
provider_id = ENV["PROVIDER_ID"]
9-
dest = ENV["DEST"] || "tmp/cmes.xml"
9+
dest = ENV["DEST"] || "tmp/all_providers_test.xml"
1010

1111
language = if lang_param.present?
1212
Language.find_by(id: lang_param) || Language.find_by(code: lang_param) || Language.find_by(name: lang_param)
@@ -33,8 +33,24 @@ namespace :xml do
3333
else
3434
path = Rails.root.join(dest)
3535
FileUtils.mkdir_p(File.dirname(path))
36-
File.write(path, xml)
36+
File.write(path, xml.encode("UTF-8", invalid: :replace, undef: :replace, replace: "�"), mode: "w:utf-8")
3737
puts "Wrote XML to #{path} (#{xml.bytesize} bytes)"
38+
39+
# Upload to Azure using FileWorker
40+
require_relative "../../app/services/file_worker"
41+
share = ENV["AZURE_STORAGE_SHARE_NAME"]
42+
name = File.basename(path)
43+
azure_path = "" # root directory in Azure
44+
file_content = File.binread(path)
45+
46+
FileWorker.new(
47+
share: share,
48+
name: name,
49+
path: azure_path,
50+
file: file_content
51+
).send
52+
53+
puts "Uploaded #{name} to Azure File Share #{share} (root directory)"
3854
end
3955
end
4056
end

0 commit comments

Comments
 (0)