Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7928161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:39:57+00:00 2026-06-03T19:39:57+00:00

I am using MSSQL 2005. I have StringIO object that contains my zip file

  • 0

I am using MSSQL 2005.

I have StringIO object that contains my zip file content.

Here is how I obtain zip binary data:

    stringio = Zip::ZipOutputStream::write_buffer do |zio|
        Eclaim.find_by_sql("SET TEXTSIZE 67108864")
        zio.put_next_entry("application.xml")
        #zio.write @claim_db[:xml]
        biblio = Nokogiri::XML('<?xml version="1.0" encoding="utf-8"?>' + @claim_db[:xml], &:noblanks)
        zio.write biblio.to_xml

        builder = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
            xml.documents {
                docs.where("ext not in (#{PROHIBITED_EXTS.collect{|v| "'#{v}'"}.join(', ')})").each{|doc|
                    zio.put_next_entry("#{doc[:materialtitle_id]}.#{doc[:ext]}")
                    zio.write doc[:efile]

                    xml.document(:id => doc[:materialtitle_id]) {
                        xml.title doc[:title]
                        xml.code doc[:code]
                        xml.filename "#{doc[:materialtitle_id]}.#{doc[:ext]}"
                        xml.extname doc[:ext]
                    }

                }
            }
        end

        zio.put_next_entry("docs.xml")
        zio.write builder.to_xml
    end

    stringio

In my controller I try:

data.rewind
@claim.docs.create(
    :title => 'Some file',
    :ext => 'zip',
    :size => data.length,
    :receive_date => Time.now,
    :efile => data.sysread
)

But Rails complains invalid byte sequence in UTF-8

Help me pls with it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T19:39:59+00:00Added an answer on June 3, 2026 at 7:39 pm

    If the stream is configured as UTF-8 stream, you can’t write compressed binary (which may contain any value).

    I think, setting data as binary stream before write:

    data.force_encoding "ASCII-8BIT"
    

    might help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table ClassAttendance and I'm using MSSQL 2005 studentID attendanceDate status -------------------------------------
I want to create a full text search using MsSql 2005. Here is the
I am using MSSQL Server 2005. In my db, I have a table customerNames
I have been using MSSQL 2005 with Rails for quite a while now, and
I am using: Rails 3.0.9 MSSQL 2005 I have the table: CREATE TABLE [dbo].[edocs](
I'm using: Rails 3.0.9 Activerecord-sqlserver-adapter 3.0.15 TinyTds MSSQL 2005 I have following table: CREATE
I am using MSSQL 2005 Server and I have the following SQL query. IF
I have a Java application using Hibernate to communicate with a MsSQL 2005 server,
I'm using MS SQL 2005 and I have created a CTE query to return
I'm using MSSQL 2005 Reporting Services and in this case I need to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.