Valeu Sérgio!

No ano passado, na empresa onde eu trabalhava, tive
que fazer essa opção, para trabalhar com imagem e
optei por file system.
Aqui, onde estou agora, optaram por salvar em blob...
fui contra, mas...

[]´s

Luis Alberto.

--- SERGIO RICARDO ANDRADE DE CARVALHO
<[EMAIL PROTECTED]> escreveu:

> Caro Luis,
> 
> Pense bem se voce deve realmente gravar estes
> arquivos de som dentro dos campos blobs, se não
> tiver outra opção procure compactar os arquivos
> antes de gravá-los, e antes de reproduzi-los
> descompacte-os. 
> Não é recomendada a gravação de arquivos .AVI dentro
> de blobs, principalmente se os arquivos forem
> grandes.
> O ideal é que voce grave em uma tabela do banco, o
> endereço dos arquivos .AVI que serão gravados em um
> determinado file system, que pode ser um diretório
> do windows server, de um storage, do samba (linux),
> netware (novell), etc.
> Em 2002 tive de escolher entre em gravar arquivos
> dos tipos: .MP3, .DOC, .XLS, .PDF, etc em campos
> Blob ou em File System, e hoje que tenho por volta
> 12.000.000 de registros no Interbase (o GDB está
> hoje com 6.7 Gb) dou graças a Deus de ter escolhido
> o File System ao invés do blob, voce imagina o
> tamanho que o GDB estaria hoje se a escolha fosse o
> Blob ?....
> Tem um exemplo em
> http://bdn.borland.com/article/0,1410,25364,00.html
> que funciona legal.
> 
> 
>                         Atenciosamente,
> 
>         Sérgio Ricardo Andrade de Carvalho    
>          Divisão de Sistemas Administrativos    
>        [EMAIL PROTECTED] - (11) 3012-1024      
>                  http://www.trf3.gov.br             
>  
> 
> 
> >>> [EMAIL PROTECTED] 10/27/05 10:51 am
> >>>
> Pessoal,
> 
> Estou precisando trabalhar com som, na minha
> aplicação, que será armazenado no banco. Para isso,
> estou usando campos blob. Como não tinha a menor
> idéia
> de como fazê-lo, perguntei ao nosso amigo google e
> ele
> me respondeu com o código logo abaixo.
> O problema eh q tá dando o erro 'Invalid class
> typecast' (na linha indicada no código) e eu não tô
> conseguindo resolver.
> Alguém pode me dar uma força?
> 
> Agradeço antecipadamente.
> 
> []s
> Luis Alberto
> 
> Question and Answer Database
> 
> FAQ1181D.txt   Storing/Playing an .AVI file in a
> database
> Category   :Database/VCL
> Platform    :All
> Product    :All 32 bit  
> 
> Question:
> How can I store an AVI file in a database and then
> play AVI 
> files?
> 
> Answer:
> AVI files can be stored in BLOB (binary large
> object)
> fields. 
> The easiest way to play an AVI file stored in a BLOB
> is to write
> the BLOB data to a temporary file, then let the
> mulimedia player
> play the file. The following example demonstrates
> how
> to store 
> an AVI file to a BLOB field, and also play the AVI
> file from the
> BLOB field.
> 
> Example:
> 
> var
>   FileName : string;
> 
> {This function gets a temporary file name form the
> system}
> function GetTemporaryFileName : string;
> {$IFNDEF WIN32}
>   const MAX_PATH = 144;
> {$ENDIF}
> var
> {$IFDEF WIN32}
>   lpPathBuffer : PChar;
> {$ENDIF}
>   lpbuffer : PChar;
> begin
> {Get the file name buffer}
>   GetMem(lpBuffer, MAX_PATH);
> {$IFDEF WIN32}
> {Get the temp path buffer}
>   GetMem(lpPathBuffer, MAX_PATH);
> {Get the temp path}
>   GetTempPath(MAX_PATH, lpPathBuffer);
> {Get the temp file name}
>   GetTempFileName(lpPathBuffer,
>                   'tmp',
>                   0,
>                   lpBuffer);
> {Free the temp path buffer}
>   FreeMem(lpPathBuffer, MAX_PATH);
> {$ELSE}
> {Get the temp file name}
>   GetTempFileName(GetTempDrive('C'),
>                   'tmp',
>                   0,
>                   lpBuffer);
> {$ENDIF}
> {Create a pascal string containg}
> {the  temp file name and return it}
>   result := StrPas(lpBuffer);
> {Free the file name buffer}
>   FreeMem(lpBuffer, MAX_PATH);
> end;
> 
> {Read a AVI file into a blob field}
> procedure TForm1.Button1Click(Sender: TObject);
> var
>   FileStream: TFileStream; {to load the avi file}
>   BlobStream: TBlobStream; {to save to the blob}
> begin
> {Allow the button to repaint}
>   Application.ProcessMessages;
> {Turn off the buttons}
>   Button1.Enabled := false;
>   Button2.Enabled := false;
> {Assign the avi file name to read}
>   FileStream := TFileStream.Create(
>    
>
'C:\PROGRA~1\BORLAND\DELPHI~1\DEMOS\COOLSTUF\COOL.AVI',
>     fmOpenRead);
>   Table1.Edit;
> {Create a BlobStream for the TField Table1AVI}
>   BlobStream := TBlobStream.Create(Table1AVI,
> bmReadWrite); <------------- erro nesta linha (uso
> query em vez de table)
> {Seek to the Beginning of the stream}
>   BlobStream.Seek(0, soFromBeginning);
> {Delete any data that may be there}
>   BlobStream.Truncate;
> {Copy from the FileStream to the BlobStream}
>   BlobStream.CopyFrom(FileStream, FileStream.Size);
> {Free the streams}
>   FileStream.Free;
>   BlobStream.Free;
> {Post the record}
>   Table1.Post;
> {Enable the buttons}
>   Button1.Enabled := true;
>   Button2.Enabled := true;
> end;
> 
> {Read an avi stored in a blob, and play it}
> procedure TForm1.Button2Click(Sender: TObject);
> var
>   FileStream: TFileStream; {a temp file}
>   BlobStream: TBlobStream; {the AVI Blob}
> begin
> {Create a blob stream for the AVI blob}
>   BlobStream := TBlobStream.Create(Table1AVI,
> bmRead);
> <------------------ erro nesta linha
>   if BlobStream.Size = 0 then begin
>    BlobStream.Free;
>    Exit;
>   end;
> {Close the media player}
>   MediaPlayer1.Close;
> {Reset the file name}
>   MediaPlayer1.FileName := '';
> {Refresh the play window}
>   MediaPlayer1.Display := Panel1;
>   Panel1.Refresh;
> {if we have a temp file then erase it}
>   if FileName <> '' then
>     DeleteFile(FileName);
> {Get a temp file name}
>   FileName := GetTemporaryFileName;
> {Create a temp file stream}
>   FileStream := TFileStream.Create(FileName,
>                                    fmCreate or
> fmOpenWrite);
> {Copy the blob to the temp file}
>   FileStream.CopyFrom(BlobStream, BlobStream.Size);
> {Free the streams}
> 
=== message truncated ===



        



        
                
_______________________________________________________ 
Promoção Yahoo! Acesso Grátis: a cada hora navegada você
acumula cupons e concorre a mais de 500 prêmios! Participe!
http://yahoo.fbiz.com.br/


-- 
<<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>>

<*> Para ver as mensagens antigas, acesse:
    http://br.groups.yahoo.com/group/delphi-br/messages

<*> Para falar com o moderador, envie um e-mail para:
    [EMAIL PROTECTED]
 
Links do Yahoo! Grupos

<*> Para visitar o site do seu grupo na web, acesse:
    http://br.groups.yahoo.com/group/delphi-br/

<*> Para sair deste grupo, envie um e-mail para:
    [EMAIL PROTECTED]

<*> O uso que você faz do Yahoo! Grupos está sujeito aos:
    http://br.yahoo.com/info/utos.html

 


Responder a