File Upload without XForms instance

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

File Upload without XForms instance

s.thwaites
Hello,
I have just started looking at OPS as a basis for a dynamic VoiceXML application framework. I have a basic framework running already, many thanks for the excellent documentation and a very clean xml framework.

I am simply trying to upload .wav files from the 'voice browser'side to the server side and simply save them to the file system!

In voiceXML there is a <submit> tag that can post a multipart request. With OPS I simply use the request processor like this:

 <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   
  <p:processor name="oxf:request">
  <p:input name="config">
            <config stream-type="xs:anyURI">
                <include>/request/parameters</include>
            </config>
        </p:input>
  <p:output name="data" id="request"/>
  </p:processor>
   
  <p:processor name="oxf:xml-serializer">
    <p:input name="config">
                <config/>
        </p:input>
    <p:input name="data" href="#request"/>
  </p:processor>
 
</p:config>

and get something like this:

<?xml version="1.0" encoding="utf-8"?>
<request>
 <parameters>
  <parameter>
   <name>datafile1</name>
   <filename>\audio\welcome\file1.wav</filename>
   <content-type>audio/wav</content-type>
   <content-length>81916</content-length>
   <value xmlns:request="http://orbeon.org/oxf/xml/request-private" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:anyURI">file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000019.tmp</value>
  </parameter>
  <parameter>
   <name>textline</name>
   <value/>
  </parameter>
  <parameter>
   <name>datafile2</name>
   <filename>\audio\welcome\file2.wav</filename>
   <content-type>audio/wav</content-type>
   <content-length>81916</content-length>
   <value xmlns:request="http://orbeon.org/oxf/xml/request-private" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:anyURI">file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000020.tmp</value>
  </parameter>
 </parameters>
</request>

So far so good but with this xml info how can I save the file upload_00000020.tmp to the file system?

Am I right in thinking that the URL Generator will give me a binary stream if I configure the processor with the file URL i.e file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000020.tmp?

But how can I then save this stream to disk?

After searching the mail archives and looking at the upload example it seems that standard practice is to use XForms but this is not what I am looking for at the moment.

Any help would be apreciated.

Regards,
Steve.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: File Upload without XForms instance

Erik Bruchez
Administrator
[hidden email] wrote:
 > Hello,

 > I have just started looking at OPS as a basis for a dynamic VoiceXML
 > application framework. I have a basic framework running already,
 > many thanks for the excellent documentation and a very clean xml
 > framework.
 >
 > I am simply trying to upload .wav files from the 'voice browser'side
 > to the server side and simply save them to the file system!
 >
 > In voiceXML there is a <submit> tag that can post a multipart
 > request. With OPS I simply use the request processor like this:

[...]

 > So far so good but with this xml info how can I save the file
 > upload_00000020.tmp to the file system?
 >
 > Am I right in thinking that the URL Generator will give me a binary
 > stream if I configure the processor with the file URL i.e
 > file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000020.tmp?

Yes, it will give you an XML document containing Base64-encoded
content, as per:

   http://www.orbeon.com/ops/doc/reference-formats#binary-documents

Be sure to use <content-type>some/binary-content-type</content-type>
and <force-content-type>true</force-content-type> with the URL
generator.

 > But how can I then save this stream to disk?

You can use the File serializer, with something like:

<p:processor name="oxf:file-serializer">
   <p:input name="config">
     <config>
       <file>file-name.wav</file>
       <directory>/tmp</directory>
     </config>
   </p:input>
   <p:input name="data" href="#my-binary-document"/>
</p:processor>

The File serializer now takes either binary or text document as input,
so if you connect it directly to the URL generator, this will work
(with OPS 3.0 beta).

 > After searching the mail archives and looking at the upload example
 > it seems that standard practice is to use XForms but this is not
 > what I am looking for at the moment.

Understood.

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: File Upload without XForms instance

s.thwaites
Hello Erik,
I have done as you suggested so I can now save the uploaded file to the file
system by connecting a URL Generator to the file serializer. However the file is
of course an xml document with base64 encoded content. How can I convert this
back to a binary .wav binary file? Do I need to configure the file-serializer to
 decode the base64?

Actually all I need is a way of performing a file copy from the upload location.

Regards,
Steve.

pipeline extract:
     <p:processor name="oxf:xslt">
         <p:input name="data" href="#file-list"/>
         <p:input name="config">
             <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema" >                                  
       
                <xsl:template match="/files">
                        <xsl:apply-templates/>
                </xsl:template>

                <xsl:template match="uri">
                    <config xsl:version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <url><xsl:value-of select="."/></url>
                        <content-type>audio/wav</content-type>
                        <force-content-type>true</force-content-type>
                        <cache-control>
                            <use-local-cache>false</use-local-cache>
                        </cache-control>
                    </config>
                </xsl:template>          
                   
             </xsl:stylesheet>
         </p:input>
         <p:output name="data" id="url-config"/>
     </p:processor>

     <p:processor name="oxf:url-generator">
         <p:input name="config" href="#url-config"/>
         <p:output name="data" id="file-data"/>
     </p:processor>

     <p:processor name="oxf:file-serializer">
        <p:input name="config">
          <config>
            <file>file-name.wav</file>
            <directory>c:/tmp</directory>
          </config>
        </p:input>
        <p:input name="data" href="#file-data"/>
     </p:processor>      



Quoting Erik Bruchez <[hidden email]>:

> [hidden email] wrote:
>  > Hello,
>
>  > I have just started looking at OPS as a basis for a dynamic VoiceXML
>  > application framework. I have a basic framework running already,
>  > many thanks for the excellent documentation and a very clean xml
>  > framework.
>  >
>  > I am simply trying to upload .wav files from the 'voice browser'side
>  > to the server side and simply save them to the file system!
>  >
>  > In voiceXML there is a <submit> tag that can post a multipart
>  > request. With OPS I simply use the request processor like this:
>
> [...]
>
>  > So far so good but with this xml info how can I save the file
>  > upload_00000020.tmp to the file system?
>  >
>  > Am I right in thinking that the URL Generator will give me a binary
>  > stream if I configure the processor with the file URL i.e
>  > file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000020.tmp?
>
> Yes, it will give you an XML document containing Base64-encoded
> content, as per:
>
>    http://www.orbeon.com/ops/doc/reference-formats#binary-documents
>
> Be sure to use <content-type>some/binary-content-type</content-type>
> and <force-content-type>true</force-content-type> with the URL
> generator.
>
>  > But how can I then save this stream to disk?
>
> You can use the File serializer, with something like:
>
> <p:processor name="oxf:file-serializer">
>    <p:input name="config">
>      <config>
>        <file>file-name.wav</file>
>        <directory>/tmp</directory>
>      </config>
>    </p:input>
>    <p:input name="data" href="#my-binary-document"/>
> </p:processor>
>
> The File serializer now takes either binary or text document as input,
> so if you connect it directly to the URL generator, this will work
> (with OPS 3.0 beta).
>
>  > After searching the mail archives and looking at the upload example
>  > it seems that standard practice is to use XForms but this is not
>  > what I am looking for at the moment.
>
> Understood.
>
> -Erik
>
>
>




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: File Upload without XForms instance

Erik Bruchez
Administrator
What version of OPS are you using? If pre-3.0 beta, the File serializer
will behave as you say. The enhancement to the File serializer to
support binary and text files is fairly recent.

-Erik

Stephen Thwaites wrote:

> Hello Erik,
> I have done as you suggested so I can now save the uploaded file to the file
> system by connecting a URL Generator to the file serializer. However the file is
> of course an xml document with base64 encoded content. How can I convert this
> back to a binary .wav binary file? Do I need to configure the file-serializer to
>  decode the base64?
>
> Actually all I need is a way of performing a file copy from the upload location.
>
> Regards,
> Steve.
>
> pipeline extract:
>      <p:processor name="oxf:xslt">
>          <p:input name="data" href="#file-list"/>
>          <p:input name="config">
>              <xsl:stylesheet version="2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema" >                                  
>        
>                 <xsl:template match="/files">
>                         <xsl:apply-templates/>
>                 </xsl:template>
>
>                 <xsl:template match="uri">
>                     <config xsl:version="2.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>                         <url><xsl:value-of select="."/></url>
>                         <content-type>audio/wav</content-type>
>                         <force-content-type>true</force-content-type>
>                         <cache-control>
>                             <use-local-cache>false</use-local-cache>
>                         </cache-control>
>                     </config>
>                 </xsl:template>          
>                    
>              </xsl:stylesheet>
>          </p:input>
>          <p:output name="data" id="url-config"/>
>      </p:processor>
>
>      <p:processor name="oxf:url-generator">
>          <p:input name="config" href="#url-config"/>
>          <p:output name="data" id="file-data"/>
>      </p:processor>
>
>      <p:processor name="oxf:file-serializer">
>         <p:input name="config">
>           <config>
>             <file>file-name.wav</file>
>             <directory>c:/tmp</directory>
>           </config>
>         </p:input>
>         <p:input name="data" href="#file-data"/>
>      </p:processor>      
>
>
>
> Quoting Erik Bruchez <[hidden email]>:
>
>
>>[hidden email] wrote:
>> > Hello,
>>
>> > I have just started looking at OPS as a basis for a dynamic VoiceXML
>> > application framework. I have a basic framework running already,
>> > many thanks for the excellent documentation and a very clean xml
>> > framework.
>> >
>> > I am simply trying to upload .wav files from the 'voice browser'side
>> > to the server side and simply save them to the file system!
>> >
>> > In voiceXML there is a <submit> tag that can post a multipart
>> > request. With OPS I simply use the request processor like this:
>>
>>[...]
>>
>> > So far so good but with this xml info how can I save the file
>> > upload_00000020.tmp to the file system?
>> >
>> > Am I right in thinking that the URL Generator will give me a binary
>> > stream if I configure the processor with the file URL i.e
>> > file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000020.tmp?
>>
>>Yes, it will give you an XML document containing Base64-encoded
>>content, as per:
>>
>>   http://www.orbeon.com/ops/doc/reference-formats#binary-documents
>>
>>Be sure to use <content-type>some/binary-content-type</content-type>
>>and <force-content-type>true</force-content-type> with the URL
>>generator.
>>
>> > But how can I then save this stream to disk?
>>
>>You can use the File serializer, with something like:
>>
>><p:processor name="oxf:file-serializer">
>>   <p:input name="config">
>>     <config>
>>       <file>file-name.wav</file>
>>       <directory>/tmp</directory>
>>     </config>
>>   </p:input>
>>   <p:input name="data" href="#my-binary-document"/>
>></p:processor>
>>
>>The File serializer now takes either binary or text document as input,
>>so if you connect it directly to the URL generator, this will work
>>(with OPS 3.0 beta).
>>
>> > After searching the mail archives and looking at the upload example
>> > it seems that standard practice is to use XForms but this is not
>> > what I am looking for at the moment.
>>
>>Understood.
>>
>>-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: File Upload without XForms instance

s.thwaites
Erik,
Yeap a small case of not reading the docs properly.

I had imported OPS3.0 beta4 war into eclipse for the examples but also installed
the orbeon studio via eclipse software update. I setup a new eclipse project
with the studio wizard and I see now that this contains version 2.8.0.

After simply making a project based on the imported OPS 3.0 beta4 instead of the
studio wizard the File Serializer behaviour is as you said.

Many thanks my problem is solved.

Regards,
Steve.

Quoting Erik Bruchez <[hidden email]>:

> What version of OPS are you using? If pre-3.0 beta, the File serializer
> will behave as you say. The enhancement to the File serializer to
> support binary and text files is fairly recent.
>
> -Erik
>
> Stephen Thwaites wrote:
> > Hello Erik,
> > I have done as you suggested so I can now save the uploaded file to the
> file
> > system by connecting a URL Generator to the file serializer. However the
> file is
> > of course an xml document with base64 encoded content. How can I convert
> this
> > back to a binary .wav binary file? Do I need to configure the
> file-serializer to
> >  decode the base64?
> >
> > Actually all I need is a way of performing a file copy from the upload
> location.
> >
> > Regards,
> > Steve.
> >
> > pipeline extract:
> >      <p:processor name="oxf:xslt">
> >          <p:input name="data" href="#file-list"/>
> >          <p:input name="config">
> >              <xsl:stylesheet version="2.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema" >                              
>    
> >        
> >                 <xsl:template match="/files">
> >                         <xsl:apply-templates/>
> >                 </xsl:template>
> >
> >                 <xsl:template match="uri">
> >                     <config xsl:version="2.0"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> >                         <url><xsl:value-of select="."/></url>
> >                         <content-type>audio/wav</content-type>
> >                         <force-content-type>true</force-content-type>
> >                         <cache-control>
> >                             <use-local-cache>false</use-local-cache>
> >                         </cache-control>
> >                     </config>
> >                 </xsl:template>          
> >                    
> >              </xsl:stylesheet>
> >          </p:input>
> >          <p:output name="data" id="url-config"/>
> >      </p:processor>
> >
> >      <p:processor name="oxf:url-generator">
> >          <p:input name="config" href="#url-config"/>
> >          <p:output name="data" id="file-data"/>
> >      </p:processor>
> >
> >      <p:processor name="oxf:file-serializer">
> >         <p:input name="config">
> >           <config>
> >             <file>file-name.wav</file>
> >             <directory>c:/tmp</directory>
> >           </config>
> >         </p:input>
> >         <p:input name="data" href="#file-data"/>
> >      </p:processor>      
> >
> >
> >
> > Quoting Erik Bruchez <[hidden email]>:
> >
> >
> >>[hidden email] wrote:
> >> > Hello,
> >>
> >> > I have just started looking at OPS as a basis for a dynamic VoiceXML
> >> > application framework. I have a basic framework running already,
> >> > many thanks for the excellent documentation and a very clean xml
> >> > framework.
> >> >
> >> > I am simply trying to upload .wav files from the 'voice browser'side
> >> > to the server side and simply save them to the file system!
> >> >
> >> > In voiceXML there is a <submit> tag that can post a multipart
> >> > request. With OPS I simply use the request processor like this:
> >>
> >>[...]
> >>
> >> > So far so good but with this xml info how can I save the file
> >> > upload_00000020.tmp to the file system?
> >> >
> >> > Am I right in thinking that the URL Generator will give me a binary
> >> > stream if I configure the processor with the file URL i.e
> >> > file:/C:/DOCUME~1/STEPHE~1/LOCALS~1/Temp/upload_00000020.tmp?
> >>
> >>Yes, it will give you an XML document containing Base64-encoded
> >>content, as per:
> >>
> >>   http://www.orbeon.com/ops/doc/reference-formats#binary-documents
> >>
> >>Be sure to use <content-type>some/binary-content-type</content-type>
> >>and <force-content-type>true</force-content-type> with the URL
> >>generator.
> >>
> >> > But how can I then save this stream to disk?
> >>
> >>You can use the File serializer, with something like:
> >>
> >><p:processor name="oxf:file-serializer">
> >>   <p:input name="config">
> >>     <config>
> >>       <file>file-name.wav</file>
> >>       <directory>/tmp</directory>
> >>     </config>
> >>   </p:input>
> >>   <p:input name="data" href="#my-binary-document"/>
> >></p:processor>
> >>
> >>The File serializer now takes either binary or text document as input,
> >>so if you connect it directly to the URL generator, this will work
> >>(with OPS 3.0 beta).
> >>
> >> > After searching the mail archives and looking at the upload example
> >> > it seems that standard practice is to use XForms but this is not
> >> > what I am looking for at the moment.
> >>
> >>Understood.
> >>
> >>-Erik
>
>
>





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws