I your question to chatGPT and it gave the answer which many suggested here. (Tmp directory.) I read through the code and it seems to be ok. You could use this code as a starting point. I would imagine same