# loading blobs

**URL:** <https://forum.servoy.com/t/loading-blobs/1978>\
**Category:** Classic Servoy\
**Created:** [June 7, 2004, 12:00am UTC](https://forum.servoy.com/t/loading-blobs/1978 "2004-06-07T00:00:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![idoctor](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@idoctor](https://forum.servoy.com/u/idoctor)\
**Post date:** [June 7, 2004, 12:00am UTC](https://forum.servoy.com/t/loading-blobs/1978/1 "2004-06-07T00:00:22Z")

</div>

I have noted on a number of my methods that Servoy does not relieably read large blobs when they are indireclty loaded onto a form. Servoy does alway read them reliable when loaded onto a form that has a base table that contains the media field where you are storing the blob. I have experimented with the saveData() command but still have the problem. I have seen this happen when loading the servoy client manual as the blob. Sometimes the PDF can’t be found and other times it is found but acrobat can’t open it. It is intermittant but running the same method will fail to work \>50% of the time.

This works:  
media\_variable = application.readFile(tempFile)

This often fails to work  
forms.tableb.controller.loadRecords(tablea\_to\_tableb)  
forms.tableb.media\_field = application.readFile(tempFile)

This often fails to work  
tablea\_to\_tableb.media\_field = application.readFile(tempFile)

I am able to work around this by storing the blob into a global media variable and then calling a method on a form of proper base table to direclty load the global variable into the media field.

Example:  
globals.Media\_variable = application.readFile(tempFile)  
forms.tableb.controller.loadRecords(tablea\_to\_tableb)  
forms.tableb.method\_that\_loads\_globalmediavariableintomediafield();

John McCann

Servoy Developer  
Version R2 2.0.3-build 276  
Java version 1.4.2\_04-b05 (Windows XP)  
MS SQL backend

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [June 7, 2004, 8:14am UTC](https://forum.servoy.com/t/loading-blobs/1978/2 "2004-06-07T08:14:18Z")

</div>

if you do this:

forms.tableb.media\_field = application.readFile(tempFile)

what do you do after that with that media\_field.

And i see that you are using mysql. In the dataprovider editor, how big is that media field? is it big enough to handle the complete pdf??

---

<div class="post-metadata">

**Author:** ![idoctor](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@idoctor](https://forum.servoy.com/u/idoctor)\
**Post date:** [June 7, 2004, 9:01pm UTC](https://forum.servoy.com/t/loading-blobs/1978/3 "2004-06-07T21:01:16Z")

</div>

I am storing PDF documents in the media fields. When I want to see them I use a method that writes them to a temporary file on the hardrive and then open them with Acrobat reader. Sometimes I get a message that thier is no file and other times I get a message that the file has been damaged. I am certain the problem ocurs in storing the PDF files and not in retrieving them.

I am using MS SQL Server as the backend not MySQL.

John McCann

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [June 7, 2004, 9:25pm UTC](https://forum.servoy.com/t/loading-blobs/1978/4 "2004-06-07T21:25:52Z")

</div>

and if you write them to a “real” file on disk with a name that you know and choose youreself.

What does the file look like? Is it really complete?

---

<div class="post-metadata">

**Author:** ![idoctor](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@idoctor](https://forum.servoy.com/u/idoctor)\
**Post date:** [June 8, 2004, 5:17am UTC](https://forum.servoy.com/t/loading-blobs/1978/5 "2004-06-08T05:17:57Z")

</div>

When I use this method to store the PDF:

forms.tableb.media\_field = application.readFile(tempFile)

Writing this binary data to the hardrive does not generate a document.

When I store the PDF using this method:

globals.Media\_variable = application.readFile(tempFile)  
forms.tableb.controller.loadRecords(tablea\_to\_tableb)  
forms.tableb.method\_that\_loads\_globalmediavariableintomediafield();

Writing the binary data to hardrive generates the expected PDF document.

John McCann

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [June 15, 2004, 9:32am UTC](https://forum.servoy.com/t/loading-blobs/1978/6 "2004-06-15T09:32:25Z")

</div>

> idoctor:  
> Writing this binary data to the hardrive does not generate a document.

Wat does it generate?

Wat errors do you get as stated in your first post?

---

<div class="post-metadata">

**Author:** ![idoctor](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@idoctor](https://forum.servoy.com/u/idoctor)\
**Post date:** [June 16, 2004, 5:51am UTC](https://forum.servoy.com/t/loading-blobs/1978/7 "2004-06-16T05:51:05Z")

</div>

Jan,

I don’t really get an error when I store the BLOBS. The method just does not save the BLOB as expected so that when I go to view the BLOB I get a message that says the BLOB can’t be found.

John McCAnn

---

<div class="post-metadata">

**Author:** ![Jan\_Blok](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@Jan\_Blok](https://forum.servoy.com/u/Jan_Blok)\
**Post date:** [June 16, 2004, 7:29am UTC](https://forum.servoy.com/t/loading-blobs/1978/8 "2004-06-16T07:29:58Z")

</div>

Does the file gets written on disk? what is the size? what should the size be?

---

<div class="post-metadata">

**Author:** ![idoctor](https://avatars.discourse-cdn.com/v4/letter/i/a88e4f/32.png) [@idoctor](https://forum.servoy.com/u/idoctor)\
**Post date:** [June 25, 2004, 8:27pm UTC](https://forum.servoy.com/t/loading-blobs/1978/9 "2004-06-25T20:27:47Z")

</div>

Jan,

I think I got to the bottom of this one. I was creating the BLOB by using the PDF printer plugin. I think it was primarly a timing issue with the method trying to file the BLOB before the PDF plug in was done creating it. It seems to work now if I change the print statement so that it must complete prior to attempting to file the document.

Thanks

John McCann
