DBI::DatabaseError: Not enough SQL parameters: INSERT INTO invoices
([account], [invoice_date], [id], [pdf]) VALUES('BY0905001', '20060912
00:00:00', 13,
<binary data has been removed from the email>')
I can see the EOF marker of the pdf file at the very end of the binary
data, so I know its sending the whole shebang.
I've tried using the DBD:ADO connection and the DBD:ODBC connection,
but both fail in the same way.
Any hints on where to start with this? I don't know if it matters or
not, but on the error output there are a lot of single quote
characters. I'm assuming they're automatically escaped.
--
Marlon
Look at "Skeeterbug's" comment (#15) at
http://weblog.rubyonrails.org/2007/1/5/rails-1-2-release-candidate-2 and at
the bug report at http://dev.rubyonrails.org/ticket/6436
I don't think these are corrected; perhaps that's the problem. I know I couldn't
get acts_as_attachment storage :db_system working with SQL Server at all, but it
worked just fine with MySQL.
Ron
--
"We all had delusions in our heads,
we all had our minds made up for us,
we had to believe in something,
...so we did."
It blows up when I get to this:
mstream.write(Invoice.pdf) #Invoice.pdf is a dynamically generated pdf
blob which registers as a string
The error I get is "Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another"
I've tried, Invoice.pdf.to_a, Invoice.pdf.each_byte { |byte| byte }
each results in the same message. Here is what the adodb.stream requires
write (buffer)
buffer: Required. An array of bytes to be written to a binary Stream object
def self.binary_to_string(value)
if value.kind_of? Array
value.map {|c| c.chr}.join
else
value
end
end
--
"He's been fortunate, he cannot deny.
Redheads, blondes, brunettes, all fall for his lines"
I put multipart.rb in my ROR /lib:
#########################
require 'net/https'
require "mime/types"
class Net::HTTP::Post
def multipart_params=(param_hash={})
boundary_token = [Array.new(8) {rand(256)}].join
self.content_type = "multipart/form-data;
boundary=#{boundary_token}"
boundary_marker = "--#{boundary_token}\r\n"
self.body = param_hash.map { |param_name, param_value|
boundary_marker + case param_value
when Array
file_to_multipart(param_name, param_value[0], param_value[1])
else
text_to_multipart(param_name, param_value.to_s)
end
}.join('') + "--#{boundary_token}--\r\n"
end
protected
def file_to_multipart(key, file_content, filename)
mime_types = MIME::Types.of(filename)
mime_type = mime_types.empty? ? "application/octet-stream" :
mime_types.first.content_type
part = %Q|Content-Disposition: form-data; name="#{key}";
filename="#{filename}"\r\n|
part += "Content-Transfer-Encoding: binary\r\n"
part += "Content-Type: #{mime_type}\r\n\r\n#{file_content}\r\n"
end
def text_to_multipart(key,value)
"Content-Disposition: form-data; name=\"#{key}\"\r\n\r\n#{value}\r
\n"
end
end
###########################
Then in my controller:
##############################
def update
require 'multipart' # actually, this line's at the top, just after
the class def.
asset = Asset.new(params[:asset])
request_params = asset.attributes
request_params['upload_now']='nothingness'
if params['ul_path'].respond_to?('read')
#a file was given; TODO: add code to
#sanitize the filename, set the size, and set the extension
request_params['ul_path']= [params['ul_path'].read,
'somename.jpg']
else
request_params['ul_path']= ''
end
request_params['username']=params[:username]
request_params['pwd']=params[:pwd]
conn = Net::HTTP.new('localhost')# or whatever base URL
conn.start do |http|
request = Net::HTTP::Post.new('/uber/doc_service/landslides/
update.cfm')
request.multipart_params=request_params
@response = http.request(request)
end
render :text=>@response.body
end
###############################
It works. It's not especially pretty, but it works. Good old
Coldfusion has one big advantage: it can talk to anything MS makes, I
believe, including Access. We're going to keep using it for that
reason (if no other) until someone gets the whole ROR/SQL Server mess
hashed out.
Ron
On Feb 23, 11:34 am, "Marlon Moyer" <marlon.mo...@gmail.com> wrote:
> could you elaborate on your work around?
>