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

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
' Clear all content output from the buffer stream
Response.BufferOutput = True
' 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.

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.

Jun 12, 2012, 10:19 AM

I think you should set up

isUpload : true
in a DirectMethod config.


App.direct.TestDirectMethod(params, {
isUpload : true

Does it help?

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


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


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.