0

I have a WCF Data Services running and JayData as a client. I now want to upload a file en put it in a blob in the database. I created a entity with a binary scalar property and a string property for the file name.

JaySvcUtil creates my JayDataContext.js just fine like this:

$data.Entity.extend('Entities.Plugin', {
    'Id': { 'key':true,'type':'Edm.Int32','nullable':false,'computed':true },
    'Data': { 'type':'Edm.Binary','nullable':false,'required':true },
    'FileName': { 'type':'Edm.String','nullable':false,'required':true }
  });

Does anybody know how to upload a file to WCF Data Service using Javascript?

Thank you

HansElsen
  • 1,639
  • 5
  • 27
  • 47

1 Answers1

1

The Data field can be field can be set with Base64 string - JayData 1.3 might offer other options, but the base64 is the way to go with the current stable version (1.2.7). You can use HTML5 File API to get the Base64 string from your local file. I hope this helps! Let me know about your results.

Robesz
  • 1,646
  • 11
  • 13
  • Thanks for the reply. I've used another solution, which probably isn't better. I created a php which downloads the file. THen exposing it to the public. Then JayData adds the URL of the file in the database. – HansElsen Apr 18 '13 at 08:07