this is driving me mad, I can't find a single example that explains how to use the internetwritefile function in the wininet.dll (well in simple plain english anyway).
i've found this
but this is not VBA and doesn't make sense to me.
why is a buffer defined as a string when uploading a BINARY file, what bit sets the file size, what bit tells it the chunk size to upload, what bit uploads the chunk, what bit keeps track of what is already uploaded, what bit keeps track of the remainder when the file isn't divisible by the chunk size exactly , there will be some bytes left over won't there.
It's driving me mad, because I know it's actually quite simple to do if someone bothered to write proper code with comments, but not even MS has examples of how to upload a file using this API.
Someone PLEASE HELP!
i've found this
Code:
INTERNET_BUFFERS ibBuffer;
ZeroMemory (& ibBuffer, sizeof (INTERNET_BUFFERS));
ibBuffer.dwStructSize = sizeof (INTERNET_BUFFERS);
ibBuffer.dwBufferTotal = nBufferSize;
if ( !HttpSendRequestEx (hRequest, & ibBuffer,
NULL, HSR_INITIATE, 0))
{
// handle error
}
// now enter the buffer in chunks of 1024 bytes
DWORD dwBytesSend;
int nPortion = nBufferSize / 10;
const int nMinToSend = __max (nPortion, g_HTTPChunkSize);
int nChunkSize = nMinToSend;
int nBufferPos = 0;
int nPrevPercentage = 0;
char *pBufferPtr = g_szGlobalBuffer;
while (nBufferPos < nBufferSize)
{
if (! InternetWriteFile (hRequest, pBufferPtr, nChunkSize,
& dwBytesSend))
{
m_WSError.SetErrorDescr (L"InternetWriteFile", __FILE__,
__LINE__, GetLastError ());
HttpEndRequest (hRequest, NULL, 0, 0);
goto Cleanup;
}
pBufferPtr += nChunkSize;
nBufferPos += nChunkSize;
if (nBufferSize - nBufferPos < nMinToSend)
nChunkSize = nBufferSize - nBufferPos;
else
nChunkSize = nMinToSend;
}
but this is not VBA and doesn't make sense to me.
why is a buffer defined as a string when uploading a BINARY file, what bit sets the file size, what bit tells it the chunk size to upload, what bit uploads the chunk, what bit keeps track of what is already uploaded, what bit keeps track of the remainder when the file isn't divisible by the chunk size exactly , there will be some bytes left over won't there.
It's driving me mad, because I know it's actually quite simple to do if someone bothered to write proper code with comments, but not even MS has examples of how to upload a file using this API.
Someone PLEASE HELP!