Importing attachments in the form of XML file in chunked 4k format

akram6
Kilo Contributor

Hi All,

I have a requirement where File attachments need to Bulk import in to Servicenow.I find out that ServiceNow supports export and import of attachments(In bulk) in XML format.but I found that it it very tricky to divide the file in to 4k chunks.When I observed how chunking is performed in servicenow.first the entire file is converted in to Gzip than divide that zipped file in to chunks of 4K and do Base64 encoding on each chunk.The thing which I find it difficult to understand is chunking part.

Let me give an Example,

I have a text file(Mime type:text/plain) of size 12 bytes.When it got compressed it is converted in to 32 bytes when refer to the sys_attachment table(Field Name:Size compressed).if it got chunked ideally only one chunk will be created in sys_attachment_doc table as the compressed size of the file is much lesser than chunk size(32 bytes<<<<<4kb).but I observed 2 sys_attachment_doc entries.

I didn't understand how chunking is happening in ServiceNow platform.If any body can guide me that will be helpful for converting our legacy attachment files in to 4k chunks and place them in XML to achieve bulk file import using XML.

2 REPLIES 2

Mike Allen
Mega Sage

It looks to me like ServiceNow creates at least two files, regardless of size.   The data in the first file must be like metadata or something along that line.   Here is a capture of 4 attachments I uploaded: one 116bytes, one 1.8kb, one 700bytes, and one 10MB:



find_real_file.png



Maybe in the larger files, it stores all metadata in the first chunk.   In smaller ones, it looks like it splits it out.


Hi Allen,



Yes,In smaller files which are less than 4MB in size the first chunk is always the same content.May be it is meta data.But in larger files which have mime types as application/pdf or application/vnd.ms-excel there are many more chunks than Expected number of chunks.So if serviceNow is holding Meta data in chunks,Is there a way to find out what is that meta data.