It sounds like you're trying to access a Document Attachment through a unique URL of
/url?file=doc_1.pdf which has no context of the document the attachment is attached to?
You could do something like:
// Take file name from query string, just using a local variable as example.
var fileName = "doc_1.pdf";
var attachment = AttachmentInfoProvider.GetAttachments()
But doing this would just get the first match in the database with this file name. The file name might not be unique as it might be uploaded to multiple documents across different cultures (if the site has multiple cultures).
Ideally you would want to include DocumentGUID or something so you could filter down the list further.