Пример #1
0
        public void SendFilePayload(Data filePayload, string endpointID, Uri uri)
        {
            string fileName             = FileUtil.getFileRealNameFromUri(this, uri);
            string filenameMessage      = filePayload.Id + ":" + fileName;
            Data   filenameBytesPayload = Data.FromBytes(System.Text.Encoding.UTF8.GetBytes(filenameMessage));

            mTransferEngine.SendData(endpointID, filenameBytesPayload).AddOnSuccessListener(new TaskListener(this, "Send File Name " + fileName)).AddOnFailureListener(new TaskListener(this, "send File Name " + fileName));
            mTransferEngine.SendData(endpointID, filePayload).AddOnSuccessListener(new TaskListener(this, "Send File " + filePayload.Id)).AddOnFailureListener(new TaskListener(this, "send File " + filePayload.Id));
            Dialog = new DialogLoader(this, 0, "Sending File...", filePayload.AsFile().Size, 0, filePayload.Id);
            Dialog.StartDialogLoading();
        }
Пример #2
0
        public void ProcessFilePayload(long payloadId)
        {
            Log.Debug(TAG, "processFilePayload, payloadId=========" + payloadId);
            Data   filePayload = IncomingFilePayloads[payloadId];
            string filename    = FilePayloadFilenames[payloadId];

            Log.Debug(TAG, "received file: " + filename);
            if (filePayload != null && filename != null)
            {
                Java.IO.File payloadFile = filePayload.AsFile().AsJavaFile();
                Log.Debug(TAG, "processFilePayload, payloadFile name------>>>>>>: " + payloadFile.Name);
                Dialog = new DialogLoader(this, 0, "Receving File...", 0, 0, payloadId);
                Dialog.StartDialogLoading();
                Java.IO.File targetFileName = new Java.IO.File(payloadFile.ParentFile, filename);

                bool result = payloadFile.RenameTo(targetFileName);
                if (!result)
                {
                    Log.Error(TAG, "rename the file failed.");
                }
            }
        }