Search the Community
Showing results for tags 'blob'.
Found 7 results
-
Console Application - Enviar arquivos JSON para uma Conta de Armazenamento Azure (Blob)
ghlevin posted a topic in .NET
Possuo uma Console Application em C# que faz a extração de dados do Dynamics 365 Customer Voice, da Microsoft. O código abaixo pega dados de tabelas de Projetos, Pesquisas, Perguntas e Respostas respectivamente. Os dados extraídos vão para arquivos JSON que ficam salvos no meu HD. using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using System; using System.Collections.Generic; using System.Linq; using System.Text; using UmbracoMVC.App_Code.Infrastructure.CRMIntegration.Business; using System.IO; using Microsoft.Crm.Sdk.Messages; using System.Globalization; using E2BWorkflow.Classes; using System.Web.Management; using System.ServiceModel; using System.Drawing; using System.Web.UI.WebControls; using System.Web.Script.Serialization; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { GetCustomerVoice(); } public static void GetCustomerVoice() { IOrganizationService crmServiceTo; crmServiceTo = Connect.Crm("myemail@e-mail.com", "mypassword", "https://mydynamics.crm4.dynamics.com/XRMServices/2011/Organization.svc"); // Get Projects QueryExpression qP = new QueryExpression("msfp_project"); qP.ColumnSet = new ColumnSet(true); var projects = crmServiceTo.RetrieveMultiple(qP); foreach (var p in projects.Entities) { msfp_project project = p.ToEntity<msfp_project>(); } var projectsList = projects.Entities.Select( s => new { msfp_projectId = s.Attributes["msfp_projectid"], msfp_name = s.Attributes["msfp_name"] } ).ToList(); var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(projectsList); System.IO.File.WriteAllText(@"C:\MyDirectory\projects.json", json); // Get Surveys QueryExpression qS = new QueryExpression("msfp_survey"); qS.ColumnSet = new ColumnSet(true); var surveys = crmServiceTo.RetrieveMultiple(qS); foreach (var s in surveys.Entities) { msfp_survey survey = s.ToEntity<msfp_survey>(); } var surveysList = surveys.Entities.Select( s => new { msfp_surveyId = s.Attributes["msfp_surveyid"], msfp_name = s.Attributes.Contains("msfp_name") ? s.GetAttributeValue<string>("msfp_questiontext") : "", msfp_anonymousurl = s.Attributes.Contains("msfp_anonymousurl") ? s.GetAttributeValue<string>("msfp_anonymousurl") : "", msfp_friendlyname = s.Attributes.Contains("msfp_friendlyname") ? s.GetAttributeValue<string>("msfp_friendlyname") : "", msfp_surveyurl = s.Attributes.Contains("msfp_surveyurl") ? s.GetAttributeValue<string>("msfp_surveyurl") : "", msfp_projectId = s.Attributes.Contains("msfp_project") && s.GetAttributeValue<EntityReference>("msfp_project").Id != null ? s.GetAttributeValue<EntityReference>("msfp_project").Id : Guid.Empty } ).ToList(); jsonSerialiser = new JavaScriptSerializer(); json = jsonSerialiser.Serialize(surveysList); System.IO.File.WriteAllText(@"C:\MyDirectory\surveys.json", json); // Get Questions QueryExpression qQ = new QueryExpression("msfp_question"); qQ.ColumnSet = new ColumnSet(true); var questions = crmServiceTo.RetrieveMultiple(qQ); foreach (var q in questions.Entities) { msfp_question question = q.ToEntity<msfp_question>(); } var questionsList = questions.Entities.Select( s => new { msfp_questionId = s.Attributes["msfp_questionid"], msfp_questionText = s.Attributes.Contains("msfp_questiontext") ? s.GetAttributeValue<string>("msfp_questiontext") : "", msfp_surveyId = s.Attributes.Contains("msfp_survey") && s.GetAttributeValue<EntityReference>("msfp_survey").Id != null ? s.GetAttributeValue<EntityReference>("msfp_survey").Id : Guid.Empty } ).ToList(); jsonSerialiser = new JavaScriptSerializer(); json = jsonSerialiser.Serialize(questionsList); System.IO.File.WriteAllText(@"C:\MyDirectory\questions.json", json); //Get Question Responses QueryExpression qR = new QueryExpression("msfp_questionresponse"); qR.ColumnSet = new ColumnSet(true); var responses = crmServiceTo.RetrieveMultiple(qR); foreach (var r in responses.Entities) { msfp_questionresponse response = r.ToEntity<msfp_questionresponse>(); } var responsesList = responses.Entities.Select( s => new { msfp_questionresponseId = s.Attributes["msfp_questionresponseid"], msfp_questionresponse = s.Attributes["msfp_name"], msfp_questionId = s.GetAttributeValue<EntityReference>("msfp_questionid").Id } ).ToList(); jsonSerialiser = new JavaScriptSerializer(); json = jsonSerialiser.Serialize(responsesList); System.IO.File.WriteAllText(@"C:\MyDirectory\responses.json", json); Console.WriteLine("END"); Console.ReadKey(); } } } Agora o que eu preciso é que esses JSONs sejam salvos dentro de um contêiner de um blob em uma Conta de Armazenamento Azure. Procurei várias soluções na Internet, mas não estou bem certo do que deveria usar em uma Console Application. -
Olá... estou enfrentando um problema e não estou conseguindo solucionar. Tenho arquivos BLOB gravados no banco de dados, e estou tentado apresentá-los em PDF na página, assim que o usuário clicar no link correspondente. A linguagem usada é PHP. Vocês poderiam me ajudar ?
-
javascript Upload de arquivo gerado no código no servidor
GiovannaRamos posted a topic in Javascript
Olá pessoal, gostaria de adicionar outra função ao meu botão 'Finalizar10()' , por enquanto ele faz a exportação dos dados da minha 'tabela' para um Excel e salva na pasta downloads do meu computador, alguém sabe se teria alguma forma fazer esse arquivo gerado (Excel) ao invés de fazer download, fazer o upload no caminho do meu servidor? function Finalizar10() { $(document).ready(function Finalizar() { $("#btnExport").click(function exportar (e) { e.preventDefault(); var blobData = new Blob(['\ufeff'+tabela], { type: 'application/vnd.ms-excel' }); var url = window.URL.createObjectURL(blobData); var a = document.createElement('a'); a.href = url; a.download = codigo; a.click(); }); }); } -
Pessoal, preciso de uma ajuda, Tenho que salvar fotos de ferramentas e peças em um banco de dados, essas fotos vão ser tiradas, mas tiradas com uma câmera usb. estou tendo dificuldades para fazer isso. Consigo pegar o código setado na outra pagina normal, a imagem da câmera também esta na variavel. Falta apenas a parte de salvar. segue abaixo o meu codigo. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Fotos</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> video{ max-width:200%; } img{ max-width:30%; } </style> </head> <body> <video autoplay></video> <script> (function() { 'use strict'; var video = document.querySelector('video') , canvas; /** * generates a still frame image from the stream in the <video> * appends the image to the <body> */ function takeSnapshot() { var img = document.querySelector('img') || document.createElement('img'); var context; var width = video.offsetWidth , height = video.offsetHeight; canvas = canvas || document.createElement('canvas'); canvas.width = width; canvas.height = height; context = canvas.getContext('2d'); context.drawImage(video, 0, 0, width, height); img.src = canvas.toDataURL('image/png'); document.body.appendChild(img); } // use MediaDevices API // docs: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia if (navigator.mediaDevices) { // access the web cam navigator.mediaDevices.getUserMedia({video: true}) // permission granted: .then(function(stream) { video.src = window.URL.createObjectURL(stream); video.addEventListener('click', takeSnapshot); }) // permission denied: .catch(function(error) { document.body.textContent = 'Could not access the camera. Error: ' + error.name; }); } })(); </script> <?php include "../lib/config.inc.php"; $foto = "<script>document.write(canvas)</script>"; echo '</br>'; echo "$foto"; echo '</br>'; $numero = $_GET['codigo']; echo $numero; $query="Insert into snapshot (codigo_ferramenta, Image) values('$numero','$foto')"; $result= $this->query($query); if($result){ return "Image saved to database"; } else{ return "Image not saved to database"; } ?> </body> </html>
- 1 reply
-
- cadastro
- banco de dados
- (and 4 more)
-
Pessoal boa tarde, estou com um grande problema Criei um código para gravar imagens no banco como mediumblob até ai blz. mas quando vou chamar na tela da erro na imagem, aparece uma tela preta com o iconeca da imagem em branco (um quadrado branco) fiz o teste em uma tabela simples, só com uma chave primaria, e ok chama normal, mas quando vou usar na tabela que devo que tem 2 chaves primarias não sei como chamar... se alguem poder me ajudar agradeço para fazer uma pesquisa nessa tabela tenho que saber o cliente que é e o código do cliente (um cliente pode ter vários códigos e cada código uma imagem diferente) CLI_COD (CODIGO DO CLIENTE) CON_COD (CODIGO DO CONTRATO) CON_ARQ_ID ID DO CODIGO DO ARQUIVO) segue o codigo: Tela que incluir os dados: <?php if(count($_FILES) > 0) { if(is_uploaded_file($_FILES['userImage']['tmp_name'])) { require_once "db.php"; $imgData =addslashes(file_get_contents($_FILES['userImage']['tmp_name'])); $imageProperties = getimageSize($_FILES['userImage']['tmp_name']); $sql = "UPDATE eAMS.CONTRATO SET CON_ARQ_TYPE='{$imageProperties['mime']}', CON_ARQ_CONTRATO='{$imgData}' WHERE CLI_COD='BOT' and CON_COD='005' and CON_ARQ_ID='7'"; $current_id = mysqli_query($conn, $sql) or die("<b>Error:</b> Problem on Image Insert<br/>" . mysqli_error($conn)); if(isset($current_id)) { header("Location: listImages.php"); } } } ?> <HTML> <HEAD> <TITLE>Upload Image to MySQL BLOB</TITLE> <link href="imageStyles.css" rel="stylesheet" type="text/css" /> </HEAD> <BODY> <form name="frmImage" enctype="multipart/form-data" action="" method="post" class="frmImageUpload"> <label>Upload Image File:</label><br/> <input name="userImage" type="file" class="inputFile" /> <input type="submit" value="Submit" class="btnSubmit" /> </form> </div> </BODY> </HTML> tela que lista os dados: <?php require_once "db.php"; $sql = "SELECT CON_ARQ_ID FROM eAMS.CONTRATO where CLI_COD='BOT' ORDER BY CON_ARQ_ID DESC"; $result = mysqli_query($conn, $sql); ?> <HTML> <HEAD> <TITLE>List BLOB Images</TITLE> <link href="imageStyles.css" rel="stylesheet" type="text/css" /> </HEAD> <BODY> <?php while($row = mysqli_fetch_array($result)) { ?> <img src="imageView.php?image_id=<?php echo $row["CON_ARQ_ID"]; ?>" /><br/> <?php } mysqli_close($conn); ?> </BODY> </HTML> Script que chama a imagem: <?php require_once "db.php"; if(isset($_GET['image_id'])) { $sql ="SELECT CON_ARQ_TYPE, CON_ARQ_CONTRATO FROM eAMS.CONTRATO WHERE CON_ARQ_ID='".$_GET['image_id']."' and CLI_COD='BOT'"; $result = mysqli_query($conn, $sql) or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysqli_error($conn)); $row = mysqli_fetch_array($result); header("Content-type: " . $row["CON_ARQ_TYPE"]); echo $row["CON_ARQ_CONTRATO"]; } mysqli_close($conn);
-
[Resolvido] COMO RECUPERAR UM ARQUIVO BLOB DO MYSQL E SALVAR NUMA PASTA COM PHP
novoAquiNoForum posted a topic in PHP
Olá Pessoal, Estou com uma dúvida sagaz, tenho uma coluna tipo BLOB no MYSQL, a qual armazena arquivos PDF's enviados a partir do upload. Não salvo o arquivo em pasta na hora do UPLOAD, somente salvo no banco de dados, sei que não é aconselhável, mas tenho meus motivos para fazer desta forma. Emfim, agora preciso fazer um script em PHP que recupere este arquivo do banco e baixe ou salve direto numa pasta que tenho, pois depois preciso enviar estes arquivos como anexo em e-mail, através do PHP Mailer, pois acho que é o único jeito de fazer. Alguém tem uma luz aí? -
Galera, seguinte. Estou trabalhando em uma aplicação asp onde o usuário tem uma foto de perfil que deverá ser armazenada em um campo BLOB no MySQL. Meu problema é como dar um insert de uma imagem recebida de um campo 'file' (form html) no MySQL....e se possível no insert pegar o "formato da imagem" para poder resgatar ela posteriormente de maneira mais fácil! Alguem pelo amor de Deus (kkkkkkkk) pode me ajudar? Eu desisti de procurar esse script na net....não achei nada parecido! Abraços!!!!!!!!