Пример #1
0
        public async Task <BE_MemoryStream> GetDownloadFileGoogleDrive(BE_TxRegistroDocumento entidad)
        {
            DriveApiService googleApiDrive = new DriveApiService();
            var             data           = await googleApiDrive.Download(entidad.IdGoogleDrive);


            return(data);
        }
Пример #2
0
        //public async Task<BE_File> GetDownloadFileGoogleDriveBase64(BE_TxRegistroDocumento entidad)
        //{
        //    DriveApiService googleApiDrive = new DriveApiService();
        //    var data = await googleApiDrive.Download(entidad.IdGoogleDrive);

        //    byte[] bytes;
        //    bytes = data.FileMemoryStream.ToArray();

        //    string base64 = Convert.ToBase64String(bytes);

        //    return new BE_File {
        //        FileBase64 = base64,
        //        Name = data.NameFile,
        //        Type = data.TypeFile
        //    };
        //}

        public async Task <BE_File> GetDownloadFileGoogleDriveSave(BE_TxRegistroDocumento entidad)
        {
            DriveApiService googleApiDrive = new DriveApiService();
            var             data           = await googleApiDrive.Download(entidad.IdGoogleDrive);

            byte[] bytes;
            bytes = data.FileMemoryStream.ToArray();

            var nombreAleatorio = GenerarCodigo();

            /*
             *  Desarrollo
             \\\\SERVIDOR95\\Users\\InvetsaNet\\Documents\\Auditoria\\INCUBA-FrontEnd\\src\\assets\\file-pdf\\
             *  Produccion
             \\\\SERVIDOR96\\Users\\adminauditoria\\Documents\\Auditoria\\Invetsa\\assets\\file-pdf\\
             */

            using (FileStream
                   fileStream = new FileStream("\\\\SERVIDOR96\\Users\\adminauditoria\\Documents\\Auditoria\\fileExtranet\\" + nombreAleatorio + ".pdf", FileMode.Create))
            {
                // Write the data to the file, byte by byte.
                for (int i = 0; i < bytes.Length; i++)
                {
                    fileStream.WriteByte(bytes[i]);
                }

                // Set the stream position to the beginning of the file.
                fileStream.Seek(0, SeekOrigin.Begin);
            }

            return(new BE_File
            {
                Name = data.NameFile,
                NameAleatorio = nombreAleatorio,
                Type = data.TypeFile
            });
        }