A 2.2GB *document* is crazy. That's over 432,000 letter-sized pages of text.
I see two solutions...
1) You'll need to improve the indexing to break this document down into smaller documents.
2) You'll probably have to send the file in several pieces as well.
As for why it's successful manually... Are you sure the entire document is getting loaded, and that it's not getting truncated silently?
The limitation is related to the 32-bit address space - it can only calculate the size/offset of a document up to the 2GB mark. After that, it overflows and your data gets corrupted.
-JD.