NetTalk Central

Author Topic: FILETOBLOB problem in NT?  (Read 3683 times)

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
FILETOBLOB problem in NT?
« on: June 18, 2014, 09:42:47 PM »
What's going on here?

The following code works in a regular Clarion proc but not when used inside a netwebform:

if FILETOBLOB(w:DocumentFile,WEBDOC:TheDocument)
   message(errorcode() & '-' & clip(error()),'FILETOBLOB ERROR')
end

w:DocumentFile holds the full path to a previously uploaded file (in /uploads/) and FILETOBLOB does NOT throw an error but the file doesn't get stored in the field either. There are other fields in the record and they get primed ok (and the record does get inserted).

Any ideas?

Peter
C9
NT8.17

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: FILETOBLOB problem in NT?
« Reply #1 on: June 18, 2014, 10:54:49 PM »
the key question would be around the context of _where_ you have this code - what record is loaded, if the file is open, and so on...
perhaps an example might help.

cheers
Bruce

JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: FILETOBLOB problem in NT?
« Reply #2 on: June 19, 2014, 12:30:35 AM »

Hi Peter

I switched all my blob handling to using stringtheory's functions,
and I also use the EXISTS function after the blob call to make sure the file is there.

Not a solution to your problem but it might be an idea to try stringtheory just below and see what results you get.

eg.
     if stblob.FromBlob(doc:docblob) ! 1=success 0=failure
        if stblob.SaveFile(loc:st_filename) ! 1=success 0=failure



Johan

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: FILETOBLOB problem in NT?
« Reply #3 on: June 19, 2014, 03:36:46 AM »
Ok, I learned something today  ;)

This is happening in a netwebform procedure where I collect data not just for one file but also for several related files (using a wizard for this, but that's not really important, I think). In addition, the user may also upload one or more documents to complete the data capture and the documents will in turn get saved in the data base as well.

All the files involved are listed as Other files in the procedure.

In the PostInsert routine of the form I have code to insert records in all of the files, the only thing that didn't work was saving the documents in blobs. But  FILETOBLOB was doing it's job and did not complain in any way. There was just nothing in the blob field.

Here's what I learned: Apparently you must explicitly OPEN a file with a blob, otherwise nothing gets put in the blob and you do not get any warning! What confused me was that all the other fields got updated like they should.

I don't know if this has to do with NetTalks way of handling files or if it's plain common knowledge that I missed on the way. But it's working now  ;D

Peter

PS - Johan, thanks for your time.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: FILETOBLOB problem in NT?
« Reply #4 on: June 19, 2014, 05:40:30 AM »
I don't know how common the knowledge is, but yes, the Clarion docs state that files have to be OPEN in order to access the Blob fields. Failure to do this usually leads to a GPF. In the ABC (NetTalk) case you can do a

Access:File.Open()
Access:File.UseFile()

If in doubt always prepend your code with a call to UseFile.

cheers
Bruce