How can we sanitize an XML or SVG file when it is 10 GB in size and uploaded through TUS multipart with multiple concurrent users? The file must be uploaded to S3
Loading
How can we sanitize an XML or SVG file when it is 10 GB in size and uploaded through TUS multipart with multiple concurrent users? The file must be uploaded to S3
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tasadduq BurneyPosted Dec 8, 2025, 5:28 PM
Hey,
Hope you're keeping well.
For sanitizing a 10?GB XML/SVG in a concurrent TUS workflow, you need to avoid DOM-based parsing entirely and stream the content. Use
XmlReaderorSystem.Xml.XmlReader.Createwith async streaming from S3 via the AWS SDKGetObjectAsyncwithResponseStream) so you process and sanitize elements sequentially without loading the full file into memory. If uploads are chunked, sanitize each chunk independently before merging, and coordinate concurrency with a distributed lock (e.g., RedisRedLock) or a queue-based pipeline (Azure Storage Queue, Kafka) to ensure only one final merge pass. Disable DTD and external entity resolutionXmlReaderSettings.DtdProcessing = Prohibit) to mitigate XML injection risks, and apply schema or whitelist-based filtering during stream processing. This approach keeps memory usage predictable while maintaining throughput for multiple concurrent users.Thanks and regards,
Taz