标签: binarystream

如何在Common Lisp中创建二进制流(而不是文件)?

我有一个函数,它将一些二进制数据输出到流.但是流是抽象的,这意味着流可以是文件流,也可以是其他流.但是流必须是支持写字节功能的二进制流.我搜索但没找到答案.

我想要做的是,我有一个将一些数据转换为gif的函数.但我不想将数据输出到文件中,我想将其输出到内存中.

谢谢.

lisp binarystream

5
推荐指数
1
解决办法
1703
查看次数

使用PreparedStatement将blob设置为null

我正在使用JSF2.0创建webapplication,在mysql中,我使用数据类型存储图像MEDIUMBLOB.

要插入值,我使用PreparedStatement,如下所示.

PreparedStatement psmnt = con.prepareStatement("INSERT INTO sketchesSG002003 (userid, imageTitle, imageData, drawingComments) VALUES (?,?,?,?)");
psmnt.setLong(1, personalInfoId);
psmnt.setString(2, sketchesSG002003Title);

try {
    String fileName = FilenameUtils.getName(sketchesSG002003ImageUpload.getName());
    File image = new File(fileName);
    InputStream fis = sketchesSG002003ImageUpload.getInputStream();
    psmnt.setBinaryStream(3, fis, (int) sketchesSG002003ImageUpload.getSize());
} catch (Exception e) {
    psmnt.setBinaryStream(3, null);
}
psmnt.setString(4, sketchesSG002003Comments);
i = psmnt.executeUpdate();
Run Code Online (Sandbox Code Playgroud)

但是我收到了错误

java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;)V
Run Code Online (Sandbox Code Playgroud)

Stacktrace的某些部分是

 javax.faces.el.EvaluationException: java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;)V
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
Run Code Online (Sandbox Code Playgroud)

我认为上面的错误是声明 psmnt.setBinaryStream(3, null);

我的问题是如何将二进制数据设置为Null或Nothing?

java mysql blob binarystream

4
推荐指数
1
解决办法
5948
查看次数

C#BinaryReader无法访问已关闭的文件

控制器:

private readonly Dictionary<string, Stream> streams;

        public ActionResult Upload(string qqfile, string id)
        {
            string filename;
            try
            {
                Stream stream = this.Request.InputStream;
                if (this.Request.Files.Count > 0)
                {
                    // IE
                    HttpPostedFileBase postedFile = this.Request.Files[0];
                    stream = postedFile.InputStream;
                }
                else
                {
                    stream = this.Request.InputStream;
                }

                filename = this.packageRepository.AddStream(stream, qqfile);
            }
            catch (Exception ex)
            {
                return this.Json(new { success = false, message = ex.Message }, "text/html");
            }

            return this.Json(new { success = true, qqfile, filename }, "text/html");
        }
Run Code Online (Sandbox Code Playgroud)

添加流的方法:

        public string AddStream(Stream stream, string …
Run Code Online (Sandbox Code Playgroud)

c# asp.net stream binarystream

4
推荐指数
1
解决办法
6061
查看次数

BinaryReader - 阅读单个"BIT"?

案例:
再次尝试通过我的NIC捕获数据包,
我开发了2个Extensions用于捕获可变数量的位

    public static string ReadBits ( this BinaryReader Key , int Value )
    {
        BitArray _BitArray = new BitArray ( Value );

        for ( int Loop = 0 ; Loop > Value ; Loop++ )
        {
/* Problem HERE ---> */   _BitArray [ Loop ] = Key . ReadBoolean ( );
        }

        return BitConverter . ToString ( _BitArray . ToByteArray ( ) );
    }

    public static byte [ ] ToByteArray ( this BitArray Key )
    {
        byte [ …
Run Code Online (Sandbox Code Playgroud)

c# bitarray binaryreader binarystream

3
推荐指数
1
解决办法
6009
查看次数

二进制流到 Uint8Array - JavaScript

我从 HTTP 请求接收到以下二进制流:

HTTP请求

Document.get({id: $scope.documentId}, function(stream){

});
Run Code Online (Sandbox Code Playgroud)

角工厂

.factory('Document', ['$resource', 'DOCUMENTS_CONFIG',
    function($resource, DOCUMENTS_CONFIG) {
        return $resource(DOCUMENTS_CONFIG.DETAIL_URL, {}, {
            get: {
                method: 'GET', 
                params: {}, 
                url: DOCUMENTS_CONFIG.DETAIL_URL,
                isArray: false
            }
        });
    }
]);
Run Code Online (Sandbox Code Playgroud)

回复

控制台.log(流) 我需要将其转换为 Uint8Array。我尝试将其转换为 bas64

// Convert Binary Stream To String
var dataString = JSON.stringify(stream);

// Convert to Base 64 Data
var base64Data = window.btoa(unescape(encodeURIComponent(dataString)));  
Run Code Online (Sandbox Code Playgroud)

当我运行此命令时,我收到错误“格式错误的 uri 异常”。我也尝试过 window.btoa(dataString) 但出现“无法在“Window”上执行“btoa”:要编码的字符串包含 Latin1 范围之外的字符”。

我怎样才能将其转换为 Uint8Array?

javascript binarystream angularjs uint8t

1
推荐指数
1
解决办法
9529
查看次数