zzyycc / bulk-loader

Automatically exported from code.google.com/p/bulk-loader
0 stars 0 forks source link

Type of data requested from scripts (without extenstion for guessType) #42

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi Arthur,
i don't sure whether this would help you, but i stumbled upon the following
problem when using BulkLoader:

I load bulk images in my flash project. These images are loaded not
directly, but through php script (in order to disable direct access to
these images and grant it only to authenticated users). But sometimes a
requested image may not exist. In this case script returns 'ret=notexists'
and i check it in flash to figure out is this image or not.

But when i'm trying to load these images through BulkLoader, guessTypes
returns 'text' (because of .php extension) and then URLItem returns the
data as String and it is much harder to convert it in ByteArray and then in
BitmapData. But if i set type="image", loading doesn't go because of some
images aren't images at all (just text 'ret=...').

I see the two solutions to this problem:
1. Is to read Content-Type returned from server request and then change
type of URLItem on ImageItem for example.
2. Is to receive data as ByteArray and then convert it to String or
whatever you want. This method i actually use now. It solves in one line of
code: in URLItem, line:24, i added: loader.dataFormat =
URLLoaderDataFormat.BINARY;
Then i need to convert ByteArray to BitmapData off course, but it's not a
problem.

Regards,
Anton

Original issue reported on code.google.com by gmentat@gmail.com on 20 Jun 2008 at 9:19

GoogleCodeExporter commented 8 years ago
Hi Anton.

I sympathize with your problem, but BulkLoader is not the correct to fix it, 
since we already have the web, 
HTTP[1] for that.
If you try to access any inexistent URI, the server should return a 404 code, 
and not really on any text content 
over the response's body to inform that.

This is a principle of how the web works really ;-)

So basically, the sound manner to solve this:
- Use HTTP for that, return a 404 and recover from flash
- Load a list of available images and fetch always those you need.

Cheers
Arthur

[1]

Original comment by debert on 20 Jun 2008 at 12:12