@@ -430,11 +430,11 @@ public class IqGenerator extends AbstractGenerator {
return packet;
}
- public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String mime) {
+ public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String name, String mime) {
IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
packet.setTo(host);
Element request = packet.addChild("request", Namespace.HTTP_UPLOAD);
- request.setAttribute("filename", convertFilename(file.getName()));
+ request.setAttribute("filename", name == null ? convertFilename(file.getName()) : name);
request.setAttribute("size", file.getExpectedSize());
request.setAttribute("content-type", mime);
return packet;
@@ -130,8 +130,7 @@ public class HttpUploadConnection implements Transferable, AbstractConnectionMan
this.file.setKeyAndIv(this.key);
}
this.file.setExpectedSize(originalFileSize + (file.getKey() != null ? 16 : 0));
- message.resetFileParams();
- this.slotFuture = new SlotRequester(mXmppConnectionService).request(method, account, file, mime);
+ this.slotFuture = new SlotRequester(mXmppConnectionService).request(method, account, file, message.getFileParams().getName(), mime);
Futures.addCallback(this.slotFuture, new FutureCallback<SlotRequester.Slot>() {
@Override
public void onSuccess(@Nullable SlotRequester.Slot result) {
@@ -211,4 +210,4 @@ public class HttpUploadConnection implements Transferable, AbstractConnectionMan
this.transmitted = progress;
mHttpConnectionManager.updateConversationUi(false);
}
-}
+}
@@ -55,13 +55,13 @@ public class SlotRequester {
this.service = service;
}
- public ListenableFuture<Slot> request(Method method, Account account, DownloadableFile file, String mime) {
+ public ListenableFuture<Slot> request(Method method, Account account, DownloadableFile file, String name, String mime) {
if (method == Method.HTTP_UPLOAD_LEGACY) {
final Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD_LEGACY);
return requestHttpUploadLegacy(account, host, file, mime);
} else {
final Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD);
- return requestHttpUpload(account, host, file, mime);
+ return requestHttpUpload(account, host, file, name, mime);
}
}
@@ -95,9 +95,9 @@ public class SlotRequester {
return future;
}
- private ListenableFuture<Slot> requestHttpUpload(Account account, Jid host, DownloadableFile file, String mime) {
+ private ListenableFuture<Slot> requestHttpUpload(Account account, Jid host, DownloadableFile file, String fname, String mime) {
final SettableFuture<Slot> future = SettableFuture.create();
- final IqPacket request = service.getIqGenerator().requestHttpUploadSlot(host, file, mime);
+ final IqPacket request = service.getIqGenerator().requestHttpUploadSlot(host, file, fname, mime);
service.sendIqPacket(account, request, (a, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
final Element slotElement = packet.findChild("slot", Namespace.HTTP_UPLOAD);