Skip to content

Commit 5a0d00a

Browse files
authored
Upload test file (#418)
2 parents 37deb39 + 1c8030a commit 5a0d00a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

lib/tasks/xml.rake

Lines changed: 16 additions & 5 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"] || "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)
@@ -31,10 +31,21 @@ namespace :xml do
3131
if dest == "-"
3232
puts xml
3333
else
34-
path = Rails.root.join(dest)
35-
FileUtils.mkdir_p(File.dirname(path))
36-
File.write(path, xml)
37-
puts "Wrote XML to #{path} (#{xml.bytesize} bytes)"
34+
# Upload XML directly to Azure using FileWorker
35+
require_relative "../../app/services/file_worker"
36+
share = ENV["AZURE_STORAGE_SHARE_NAME"]
37+
name = "all_providers_test.xml"
38+
azure_path = "" # root directory in Azure
39+
file_content = xml.encode("UTF-8", invalid: :replace, undef: :replace, replace: "�")
40+
41+
FileWorker.new(
42+
share: share,
43+
name: name,
44+
path: azure_path,
45+
file: file_content
46+
).send
47+
48+
puts "Uploaded #{name} to Azure File Share #{share} (root directory)"
3849
end
3950
end
4051
end

0 commit comments

Comments
 (0)