We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Small Basic Only Extension
#22
OK, I understand the issue I think.

SmallBasicLibrary uses Network.DownloadFile for all network file access, including within ImageList.LoadImage.

The code for DownloadFile includes this to read the data:

Code:
long num = webResponse.ContentLength;
stream2 = webResponse.GetResponseStream();
while (num > 0)
{
int num2 = stream2.Read(buffer, 0, 16384);
stream.Write(buffer, 0, num2);
num -= num2;
}

This fails for Flickr image urls as we know, using Network.DownloadFile or ImageList.LoadImage.

The code I use in LDBasic.DownloadFile is slightly different (apart from the SSL stuff):

Code:
                Stream stream = webResponse.GetResponseStream();
                int readCount = stream.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                {
                    fs.Write(buffer, 0, readCount);
                    readCount = stream.Read(buffer, 0, bufferSize);
                }

So SmallBasicLibrary tests webResponse.ContentLength to check size.  Google 'webResponse.ContentLength' if interested.

The documentation for it states:

Quote:The ContentLength property contains the value of the Content-Length header returned with the response. If the Content-Length header is not set in the response, ContentLength is set to the value -1.

So, this is an 'optional' setting included in the web response header (not set by Flikr, probably changed at some point).  Standard SmalBasicLibrary cannot work for web urls that don't have this property set.
[-] The following 1 user Likes litdev's post:
  • z-s
Reply


Messages In This Thread
Small Basic Only Extension - by jrmrhrb00 - 11-02-2023, 06:09 PM
RE: Small Basic Only Extension - by litdev - 11-03-2023, 07:39 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-04-2023, 02:00 PM
RE: Small Basic Only Extension - by litdev - 11-05-2023, 02:49 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-05-2023, 03:42 PM
RE: Small Basic Only Extension - by litdev - 11-05-2023, 08:58 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-06-2023, 01:13 AM
RE: Small Basic Only Extension - by litdev - 11-06-2023, 09:13 AM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-06-2023, 02:04 PM
RE: Small Basic Only Extension - by litdev - 11-06-2023, 03:15 PM
RE: Small Basic Only Extension - by Scout - 11-06-2023, 03:17 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-06-2023, 03:39 PM
RE: Small Basic Only Extension - by litdev - 11-06-2023, 06:32 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-06-2023, 08:21 PM
RE: Small Basic Only Extension - by litdev - 11-06-2023, 09:11 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-06-2023, 09:42 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-07-2023, 02:32 PM
RE: Small Basic Only Extension - by litdev - 11-07-2023, 05:49 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-07-2023, 06:35 PM
RE: Small Basic Only Extension - by litdev - 11-07-2023, 10:32 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-07-2023, 11:00 PM
RE: Small Basic Only Extension - by litdev - 11-08-2023, 12:07 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-08-2023, 03:00 PM
RE: Small Basic Only Extension - by litdev - 11-08-2023, 08:10 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-08-2023, 08:44 PM
RE: Small Basic Only Extension - by WhTurner - 11-09-2023, 01:13 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 11-10-2023, 04:37 PM
RE: Small Basic Only Extension - by litdev - 11-10-2023, 07:31 PM
RE: Small Basic Only Extension - by jrmrhrb00 - 12-19-2023, 02:46 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)