我想通過elisp中的XML-RPC從文件(PNG圖像)傳輸一個二進制數據的blob。這是自動將附件上傳到Confluence wiki的一部分,特別是當前頁面中使用的本地圖像。 這樣的代碼:在elisp中讀取二進制數據
;; 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
這工作得很好!在此之後我可以使用(緩衝區字符串)嗎?我不希望文本屬性被返回。 – 2012-08-17 04:57:13
@NarendraAcharya可能沒有文本屬性,但使用'buffer-substring-no-properties'更安全 – npostavs 2012-08-17 15:57:33