public async Task <ulong> sendAttachment(PushAttachmentData attachment)// throws IOException
        {
            String response = await makeRequest(string.Format(ATTACHMENT_PATH, ""), "GET", null);

            AttachmentDescriptor attachmentKey = JsonUtil.fromJson <AttachmentDescriptor>(response);

            if (attachmentKey == null || attachmentKey.getLocation() == null)
            {
                throw new Exception("Server failed to allocate an attachment key!");
            }

            Debug.WriteLine("Got attachment content location: " + attachmentKey.getLocation(), TAG);

            /*uploadAttachment("PUT", attachmentKey.getLocation(), attachment.getData(),
             *               attachment.getDataSize(), attachment.getKey());
             */
            throw new NotImplementedException("PushServiceSocket sendAttachment");
            return(attachmentKey.getId());
        }
        private AttachmentPointer createAttachmentPointer(TextSecureAttachmentStream attachment)
        {
            byte[] attachmentKey = Util.getSecretBytes(64);
            PushAttachmentData attachmentData = new PushAttachmentData(attachment.getContentType(),
                                                                       attachment.getInputStream(),
                                                                       attachment.getLength(),
                                                                       attachmentKey);

            ulong attachmentId = socket.sendAttachment(attachmentData).Result;

            var builder = AttachmentPointer.CreateBuilder()
                                    .SetContentType(attachment.getContentType())
                                    .SetId(attachmentId)
                                    .SetKey(ByteString.CopyFrom(attachmentKey))
                                    .SetSize((uint)attachment.getLength());

            if (attachment.getPreview().HasValue)
            {
                builder.SetThumbnail(ByteString.CopyFrom(attachment.getPreview().ForceGetValue()));
            }

            return builder.Build();
        }
Ejemplo n.º 3
0
        public async Task<ulong> sendAttachment(PushAttachmentData attachment)// throws IOException
        {
            String response = await makeRequest(string.Format(ATTACHMENT_PATH, ""), "GET", null);
            AttachmentDescriptor attachmentKey = JsonUtil.fromJson<AttachmentDescriptor>(response);

            if (attachmentKey == null || attachmentKey.getLocation() == null)
            {
                throw new Exception("Server failed to allocate an attachment key!");
            }

            Debug.WriteLine("Got attachment content location: " + attachmentKey.getLocation(), TAG);

            /*uploadAttachment("PUT", attachmentKey.getLocation(), attachment.getData(),
                             attachment.getDataSize(), attachment.getKey());
*/
            throw new NotImplementedException("PushServiceSocket sendAttachment");
            return attachmentKey.getId();
        }