/// <summary>
        /// Get Attachments
        /// But Google Cloud Firestore doesn't support attachments
        /// </summary>
        /// <param name="entityId">attachment id</param>
        /// <param name="fileName">name of the file</param>
        /// <returns>The attachment type LightAttachment</returns>
        public override async Task <ILightAttachment> GetAttachmentAsync <T>(string entityId, string fileName)
        {
            await base.GetAttachmentAsync <T>(entityId, fileName);

            ILightAttachment lightAttachment = new LightAttachment();

            if (_mediaStorage != null)
            {
                var attachment = _mediaStorage.GetAsync("", "");
                ILightAttachment lightAttachmentStorage = await _mediaStorage.GetAsync(entityId, fileName);

                lightAttachment.MediaStream = lightAttachmentStorage.MediaStream;
            }
            else
            {
                lightAttachment = null;
            }

            return(lightAttachment);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calls the base class because there may be some generic behavior in it
        /// Get the attatchment by id and filename
        /// </summary>
        /// <param name="entityId">attachment id</param>
        /// <param name="fileName">name of the file</param>
        /// <returns>The attachment type LightAttachment</returns>
        public override async Task <ILightAttachment> GetAttachmentAsync <T>(string entityId, string fileName)
        {
            await base.GetAttachmentAsync <T>(entityId, fileName);

            ILightAttachment lightAttachment;

            if (_mediaStorage != null)
            {
                Attachment attachment = (Attachment)await _client.ReadAttachmentAsync(GetAttachmentUri(entityId, fileName));

                lightAttachment = ConvertLightAttachment(attachment);
                ILightAttachment lightAttachmentStorage = await _mediaStorage.GetAsync(entityId, fileName);

                lightAttachment.MediaStream = lightAttachmentStorage.MediaStream;
            }
            else
            {
                lightAttachment = await _client.ReadAttachmentAsync(((await _collection).SelfLink + "/" + fileName)) as ILightAttachment;
            }

            return(lightAttachment);
        }