As I recall you need to separate this for uploading the file and attaching it to a record using the doc id.
I didn’t find a way to do that but you might use the email capture features.
Send the file and the record to NetSuite email, in the email capture script download the attachment and save it and later attache it.