http-files: Report correct file size for encrypted files (slot request)

This commit is contained in:
fiaxh 2018-01-28 23:26:37 +01:00
parent 78de584ad0
commit 8c46c423c0
2 changed files with 15 additions and 15 deletions

View file

@ -32,7 +32,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
public void send_file(Conversation conversation, FileTransfer file_transfer) { public void send_file(Conversation conversation, FileTransfer file_transfer) {
Xmpp.XmppStream? stream = stream_interactor.get_stream(file_transfer.account); Xmpp.XmppStream? stream = stream_interactor.get_stream(file_transfer.account);
if (stream != null) { if (stream != null) {
stream_interactor.module_manager.get_module(file_transfer.account, UploadStreamModule.IDENTITY).upload(stream, file_transfer.input_stream, file_transfer.server_file_name, file_transfer.size, file_transfer.mime_type, stream_interactor.module_manager.get_module(file_transfer.account, UploadStreamModule.IDENTITY).upload(stream, file_transfer.input_stream, file_transfer.server_file_name, file_transfer.mime_type,
(stream, url_down) => { (stream, url_down) => {
uploaded(file_transfer, url_down); uploaded(file_transfer, url_down);
file_transfer.info = url_down; file_transfer.info = url_down;

View file

@ -15,21 +15,21 @@ public class UploadStreamModule : XmppStreamModule {
public delegate void OnUploadOk(XmppStream stream, string url_down); public delegate void OnUploadOk(XmppStream stream, string url_down);
public delegate void OnError(XmppStream stream, string error); public delegate void OnError(XmppStream stream, string error);
public void upload(XmppStream stream, InputStream input_stream, string file_name, int file_size, string file_content_type, owned OnUploadOk listener, owned OnError error_listener) { public void upload(XmppStream stream, InputStream input_stream, string file_name, string file_content_type, owned OnUploadOk listener, owned OnError error_listener) {
request_slot(stream, file_name, file_size, file_content_type, uint8[] buf = new uint8[256];
(stream, url_down, url_up) => { Array<uint8> data = new Array<uint8>(false, true, 0);
uint8[] buf = new uint8[256]; size_t len = -1;
Array<uint8> data = new Array<uint8>(false, true, 0); do {
size_t len = -1; try {
do { len = input_stream.read(buf);
try { } catch (IOError error) {
len = input_stream.read(buf); error_listener(stream, @"HTTP upload: IOError reading stream: $(error.message)");
} catch (IOError error) { }
error_listener(stream, @"HTTP upload: IOError reading stream: $(error.message)"); data.append_vals(buf, (uint) len);
} } while(len > 0);
data.append_vals(buf, (uint) len);
} while(len > 0);
request_slot(stream, file_name, (int) data.length, file_content_type,
(stream, url_down, url_up) => {
Soup.Message message = new Soup.Message("PUT", url_up); Soup.Message message = new Soup.Message("PUT", url_up);
message.set_request(file_content_type, Soup.MemoryUse.COPY, data.data); message.set_request(file_content_type, Soup.MemoryUse.COPY, data.data);
Soup.Session session = new Soup.Session(); Soup.Session session = new Soup.Session();