public Tuple <ulong, byte[]> SendAttachment(PushAttachmentData attachment)// throws IOException
        {
            string response = 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);

            byte[] digest = UploadAttachment("PUT", attachmentKey.getLocation(), attachment.getData(),
                                             attachment.getDataSize(), attachment.getKey());

            return(new Tuple <ulong, byte[]>(attachmentKey.getId(), digest));
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
0
        public async Task <(ulong id, byte[] digest)> SendAttachment(CancellationToken token, PushAttachmentData attachment)// throws IOException
        {
            var(id, location) = await RetrieveAttachmentUploadUrl(token);

            byte[] digest = await UploadAttachment(token, "PUT", location, attachment.Data,
                                                   attachment.DataSize, attachment.OutputFactory, attachment.Listener);

            return(id, digest);
        }