0

elisp で XML-RPC を介してファイル (PNG 画像) からバイナリ データのブロブを転送しようとしています。これは、Confluence wiki への添付ファイル (特に現在のページで使用されているローカル画像) の自動アップロードの一部です。これを行うコードは次のとおりです。

        ;; Open the file and get content
        (with-temp-buffer
          ;; file-name is the PNG file name, which is binary data
          (find-file (expand-file-name file-name current-dir))
          ;; Setup Confluence request alist
          (setq confl-req (list 
                           (cons "fileName" file-name)
                           (cons "contentType" mime-type)))
          ;; RPC call
          (setq confl-reply (cfln-rpc-execute 'confluence1.addAttachment
                                              page-id confl-req (buffer-substring-no-properties (point-min) (point-max))))

作品に問題があり(buffer-substring-no-properties (point-min) (point-max))ます。Confluence にアップロードされたバイナリ データは、いくつかの場所で PNG ファイルと一致しません。添付ファイルのバイト0xe0 0x88が に置き換えられていることに気付きました。0xc8ファイルに含まれる正確なバイナリ データを取得する方法はありますか?

ありがとう、NMA

4

2 に答える 2

3

insert-file-contents-literallyの代わりに使用する必要がありfind-fileます。

(insert-file-contents-literally FILENAME &optional VISIT BEG END
REPLACE)

Like `insert-file-contents', but only reads in the file literally.
A buffer may be modified in several ways after reading into the buffer,
to Emacs features such as format decoding, character code
conversion, `find-file-hook', automatic uncompression, etc.

This function ensures that none of these modifications will take place.
于 2012-08-16T20:11:55.457 に答える