Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello,
I am trying to write an html file with the help of a python recipe into a folder which is located on a blog storage.
The writing works so far, but unfortunately the content type of the file is not text/html, but application/octet-stream.
In the Element folder in Dataiku I have set the Content Type to text/html under Settings, but unfortunately this seems to be ignored.
Is there a way to do this?
def write_to_folder(html, lang):
# Write recipe outputs
# Read recipe inputs
manuals_html = dataiku.Folder("manuals_html")
with manuals_html.get_writer("html_" + lang + ".html") as w:
w.write(html.encode(encoding='UTF-8'))
print('done')
Thanks
Sascha
Operating system used: Unix
In that case the content type must be set by the APIs Dataiku is using to write the object. You will either need to call the Azure Blob APIs directly so you can have full control of the save file call or do an additional context type change call to change after Dataiku writes.
Can you explain your requirement in detail? There might be a better way of doing this.
You need to use the folder.upload_stream() method:
import dataiku
managed_folder = dataiku.Folder('Landing')
html_data = """<!DOCTYPE html>
<html>
<body>
<h1>Heading</h1>
<p>Paragraph</p>
</body>
</html>"""
managed_folder.upload_stream("my_file.html", html_data)
In that case the content type must be set by the APIs Dataiku is using to write the object. You will either need to call the Azure Blob APIs directly so you can have full control of the save file call or do an additional context type change call to change after Dataiku writes.
Can you explain your requirement in detail? There might be a better way of doing this.
Keep in mind that the content type is not a property of the file, files have no content type. They can be text files or binary files, that's about it. So if the file is still being written as a text file then the issue is with the Azure Blob object content type.