PDA

View Full Version : [CLOSED] Can I use Response object in a direct method call?



feanor91
Jun 12, 2012, 8:59 AM
Hello I experiment a lot of problem with that.

Here my direct method :



<DirectMethod()> Public Sub SaveCharts(ByVal ChartName As String, ByVal chartSVG As String)

Dim ms As New MemoryStream()
SavePNG(ms, chartSVG, ChartName)

'Convert the memorystream to an array of bytes.
Dim byteArray() As Byte = ms.ToArray()
'Clean up the memory stream
ms.Flush()
ms.Close()
' Clear all content output from the buffer stream
Response.Clear()
Response.BufferOutput = True
Response.ClearHeaders()
' Add a HTTP header to the output stream that specifies the default filename
' for the browser's download dialog
Response.AddHeader("Content-Type", "application/force-download")
Response.AddHeader("Content-Disposition", "attachment; filename=" + ChartName + ".jpg")
Response.AddHeader("Content-Length", byteArray.Length.ToString())
' Add a HTTP header to the output stream that contains the
' content length(File Size). This lets the browser know how much data is being transfered
' Set the HTTP MIME type of the output stream
Response.ContentType = "application/octet-stream"
' Write the data out to the client.
Response.BinaryWrite(byteArray)
Response.End()

End Sub

Whatever I try to get the return in the browser, I get a BADRESPONSE erreur with error code 200. so, my method is well executed, but the response is not/bad send.

To not that

SavePNG(ms, chartSVG, ChartName)

is well run and produce attende result. If I save the result to disk, I get the image saved.

I try a lot of solution since this morning and nothing seems to work. So my question.
And the fact is direct method run well, but the return no.

Daniil
Jun 12, 2012, 10:19 AM
Hi,

I think you should set up

isUpload : true
in a DirectMethod config.

Example

App.direct.TestDirectMethod(params, {
isUpload : true
});

Does it help?

feanor91
Jun 12, 2012, 11:50 AM
I will try that but if it is like the success I want to implement...

Look:

App.direct.BuildPanelByDirectMethod( Title, left, top, ChartName, panWidth, panHeight );


I have parameters in my direct method call, so how to implement this functionnality?

Edit :

I've just try:

var SaveChartClick = function (chart)
{
App.direct.SaveCharts( chart, Ext.draw.engine.SvgExporter.self.generate( null, Ext.getCmp( chart ).surface ), {
isUpload: true
} );
};

Call works, but answer still the same

4355

Edit 2:

Oups, very sorry, I misplaced the call in my code (I have a dead function to delete). Placed in good function it works.

You can close the thread.