Uploads = blob vs filelocation

This may not be necassariy be a Java question, but it's related to web services.
I have made an application that works with uploaded images by storing the image filename inside a table in a database, this image can be retrieved from a file location on the server.
Now I was thinking to change this by saving it as a binary (bytea in pgsql) in the database (can be done pretty quick in my application).
Pro's as I see it
1) db uploads are not bound by a web application (when retrieving from the database not through a web application but by something else still has the possibilty to view an image) thus improving portability
2) no extra filelocation checks
Cons
1) Complexer (arguable, perhaps handling files is more complex)
2) Bigger storage in database
Is there any other pro's / cons to saving the entire image/upload in a DB as opposed to filenames?
Thanks

hi
if the picture has big size ,,, store just the path for the picture.
if the picture has a normal size ,,, u can store it immediatly in the database.
i store images always in database ,,if the picture has big size resize it

Similar Messages

  • Uploaded blobs are not moving to RBS storage even RBS is enabled for this content db

    Hi
    In a production environment RBS  is configured for SharePoint content dbs ,
    and sql server  has failover clusters and alwayson
    Now each content db  size is very huge : mdf file : 617 GB and .ndf file292 GB
    and  RBS Storage is :  4,742,795 Files, 117 Folders  and size is 1.35 TB (1,494,447,389,036 bytes)
    and web application content organizer is enabled and
    daily many users upload documents to this web application
    here my issue is when user upload documents  these docs are saving in content db, but no count of files increased in RBS
    storage
    when I run below two queries
    Selectcount(*)fromAllDocstreamswhereRBSIDIS 
    NOTNULL
    its showing every time( 417 7813 ) its not changing every time I run the  query
    Selectcount(*)fromAllDocstreamswhereRBSIDIS  
    NULL
    when I run this query  the  count of files are  increasing every time
    count of files now is149 239 and  its keep increasing   when I run  query  bcz users are uploading docs.
    here I want to know why these  uploaded blobs are not moving to RBS storage even rbs is enabled for this content db
    ;what is the reason
    adil

    yes its working for me If I run following commands
    $cdb = Get-SPContentDatabase Original_Wss_Content_MSRBS
    $rbss = $cdb.RemoteBlobStorageSettings
    $rbss.GetProviderNames()
    $rbss.Installed()
    I don't know what happen , why blobs not going to rbs storage ,
    before two months ago I work with other company they installed migration jobs for migrate  blobs to nas storage, but they targeted to one content database only
    adil

  • How to upload blob from forms6i

    Hi,
    Anyone has idea how to upload blob
    using forms6i ?????
    Mehul

    Hi,
    Set-AzureStorageBlobContent copies a file from the host it is run on to Azure Blob Storage. Running this cmdlet on your local machine means it will copy files from your local machine to Azure Blob Storage. Running this cmdlet in a runbook means it will copy
    files from the sandbox running the runbook to Azure Blob Storage. Runbooks have no access to your local machine, since they run in Azure.
    If you want to interact with files on your local machine from within runbooks, you need to put the local files into Blob Storage, and then download them from Blob Storage within the runbook.
    Here's an example of PowerShell you could put in a runbook to download files from Blob Storage:
    $AzureConnectionName = "SomeAzureConnectionAssetName"
    $TempFileLocation = "C:\abc.cscfg"
    $StorageAccountName = "MyStorageAccount"
    $ContainerName = "MyContainer"
    $BlobName = "MyDeploymentConfig.cscfg"
    Connect-Azure -AzureConnectionName $AzureConnectionName
    InlineScript {
    Select-AzureSubscription -SubscriptionName $Using:AzureConnectionName
    $StorageAccount = (Get-AzureStorageAccount -StorageAccountName $Using:StorageAccountName).Label
    Set-AzureSubscription `
    -SubscriptionName $Using:AzureConnectionName `
    -CurrentStorageAccount $StorageAccount
    $blob =
    Get-AzureStorageBlobContent `
    -Blob $Using:BlobName `
    -Container $Using:ContainerName `
    -Destination $Using:TempFileLocation `
    -Force

  • Upload blob content

    Hi all,
    I am facing an issue, while inserting blob content into database.
    I am having a table(table1) with following column cat(char) PK,upload blob,mimetype varchar(1000),filetype varchar(1000)
    For inserting values into DB(table1) i am using the following process, here it works fine
    BEGIN
    IF (:P9_X IS NOT NULL)
    THEN
    INSERT INTO table1(cat,UPLOAD,MIMETYPE,FILETYPE)
    SELECT :p9_cat,blob_content,MIME_TYPE,FILE_TYPE FROM wwv_flow_files where name=:P9_X;
    END IF;
    END;
    But, when i tried to have ID(number PK) in table1 with above process, i am not able to insert values. While creating process it throws following error.
    INSERT INTO table1(ID,UPLOAD,MIMETYPE,FILETYPE)
    SELECT DEL_SEQ.NEXTVAL,blob_content,MIME_TYPE,FILE_TYPE FROM wwv_flow_files where name=:P9_X;
    ORA-06550: line 6, column 24: PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got BLOB ORA-06550: line 5, column 7: PL/SQL: SQL Statement ignored
    Thanks.

    Hi,
    If I understand correctly, your table UPLOAD column format is number and you try insert BLOB to it.
    Regards,
    Jari

  • How to upload BLOB

    hi phil,
    i need to upload BLOB can u please get me sample code?

    Hi,
    who's Phil ? Anyway, which technology and what content ?
    Frank

  • Problem on uploading blob file to database using KUBA's example

    I tried running KUBAS's example found on this thread [Solved]How to upload / download BLOB images ADF - JSF
    but a lot of exceptions occured...
    I'm using jdev 10.1.3.2.0(i put my jdev's libraries) and oracle database 10g as i wrote in the other thread.
    any help would be more than appreciated
    07/05/05 13:48:14 javax.faces.el.EvaluationException: oracle.jbo.common.ampool.ApplicationPoolException: JBO-30003: The application pool (zilp.testcase.model.service.BlobAMLocal) failed to checkout an application module due to the following exception:
    07/05/05 13:48:14      at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:190)
    07/05/05 13:48:14      at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:143)
    07/05/05 13:48:14      at zilp.testcase.view.util.JSFUtils.resolveExpression(JSFUtils.java:163)
    07/05/05 13:48:14 oracle.jbo.common.ampool.ApplicationPoolException: JBO-30003: The application pool (zilp.testcase.model.service.BlobAMLocal) failed to checkout an application module due to the following exception:
    07/05/05 13:48:14      at zilp.testcase.view.util.ADFUtils.getApplicationModule(ADFUtils.java:26)
    07/05/05 13:48:14      at zilp.testcase.view.backing.Uploading.uploadAction(Uploading.java:58)
    07/05/05 13:48:14      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    07/05/05 13:48:14      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    07/05/05 13:48:14      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    07/05/05 13:48:14      at java.lang.reflect.Method.invoke(Method.java:585)
    07/05/05 13:48:14      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
    07/05/05 13:48:14      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
    07/05/05 13:48:14      at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
    07/05/05 13:48:14      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:287)
    07/05/05 13:48:14      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:401)
    07/05/05 13:48:14      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
    07/05/05 13:48:14      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    07/05/05 13:48:14      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
    07/05/05 13:48:14      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
    07/05/05 13:48:14      at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    07/05/05 13:48:14      at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:228)
    07/05/05 13:48:14      at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:197)
    07/05/05 13:48:14      at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:171)
    07/05/05 13:48:14      at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:103)
    07/05/05 13:48:14      at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
    07/05/05 13:48:14      at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:162)
    07/05/05 13:48:14      at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:620)
    07/05/05 13:48:14      at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:369)
    07/05/05 13:48:14      at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:865)
    07/05/05 13:48:14      at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:447)
    07/05/05 13:48:14      at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:215)
    07/05/05 13:48:14      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
    07/05/05 13:48:14      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
    07/05/05 13:48:14      at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    07/05/05 13:48:14      at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
    07/05/05 13:48:14      at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
    07/05/05 13:48:14      at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
    07/05/05 13:48:14      at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    07/05/05 13:48:14      at java.lang.Thread.run(Thread.java:595)
    07/05/05 13:48:14 Caused by: oracle.jbo.common.ampool.ApplicationPoolException: JBO-30003: The application pool (zilp.testcase.model.service.BlobAMLocal) failed to checkout an application module due to the following exception:
    07/05/05 13:48:14      at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2002)
    07/05/05 13:48:14      at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:2793)
    07/05/05 13:48:14      at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:453)
    07/05/05 13:48:14      at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(HttpSessionCookieImpl.java:233)
    07/05/05 13:48:14      at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:424)
    07/05/05 13:48:14      at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:419)
    07/05/05 13:48:14      at oracle.adf.model.bc4j.DCJboDataControl.rebuildApplicationModule(DCJboDataControl.java:1536)
    07/05/05 13:48:14      at oracle.adf.model.bc4j.DCJboDataControl.beginRequest(DCJboDataControl.java:1396)
    07/05/05 13:48:14      at oracle.adf.model.binding.DCDataControlReference.getDataControl(DCDataControlReference.java:99)
    07/05/05 13:48:14      at oracle.adf.model.BindingContext.get(BindingContext.java:457)
    07/05/05 13:48:14      at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:79)
    07/05/05 13:48:14      at oracle.adfinternal.view.faces.model.FacesPropertyResolver.getValue(FacesPropertyResolver.java:92)
    07/05/05 13:48:14      at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:187)
    07/05/05 13:48:14      at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:171)
    07/05/05 13:48:14      at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263)
    07/05/05 13:48:14      at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:160)
    07/05/05 13:48:14      ... 37 more

    Hi,
    I don't know where is the problem - it works for me. Check precisely database connection (about JBO-30003 see: http://blogs.oracle.com/jheadstart/newsItems/departments/adfBusinessComponents/2006/08/18).
    Also note, what kind of file you are uploading. In MimeTypes class there are definitions for mime types.
    Kuba

  • Upload BLOB through Handheld application

    Hi,
    I am developing NW Mobile Handheld application with 7.10 SP10 IDE. I want to upload an image and send it to DOE. I have created a model in DOE and imported the same in NWDS. The data type for the attachment attribute generated is BLOB as expected. My question is how do i create BLOB object so that i can fill the stream in it by reading a file. In laptop application i could see createBLOB() method in model instance to create BLOB object. But i couldnt see it in model class generated in PDA application.
    Regards,
    Dhana

    Hi Dhana,
    Here is the sample code:
         public void onActionCreate (Event wdEvent) {
    //@@begin onActionCreate(ServerEvent)
                   try {
                        AttahtstModel model = (AttahtstModel) OcaRoot.getInstance().getOcaModel(AttahtstModel.class);
                        AttachmentDataObjectAttachment element = model.createAttachmentDataObjectAttachment();
                        element.setAttachmentId(-1);
                        element.setAttachmentClob("X");
                        element.setAttachmentBlob("X");
                        element.setAttachmentClobActual("This is a new record");
                        BLOB blob = (BLOB) element.getAttachmentBlobActual();
                        InputStream is = blob.getBinaryStream();                    
                        String mobileHome = new File(Configuration.getInstallationDirectory()).getCanonicalPath();
                        String imageName = "image_new.jpg";
                        File imageFile = new File(mobileHome "
    MobileApps
    demo.sap.comattuiimplementation
    Components
    com.sap.demo.attui.wd.comp.attachmentcomp.AttachmentComp
    "imageName);                    
                        FileInputStream fis = new FileInputStream(imageFile);
                        blob.setBinaryStream(fis, imageFile.length());                    
                        OcaRoot.getInstance().commit();
                        wdContext.currentContextElement().nodeAttachmentDataObjectAttachment().bind(model.getAttachmentDataObjectAttachments());
                        wdContext.reload();
                   } catch (Exception e) {
                        e.printStackTrace();
    //@@end
    Thanks and Regards,
    Suma

  • UploadedFile component - af:inputFile to upload blob Errors - help needed

    Hi,
    I am working with JDev, Toplink, and ADF Faces. I am using the af:inputFile component to read in a pdf file which I want to save as a blob into my oracle DB.
    This is the code on the jspx page:
    <af:inputFile label="Label 1"
    binding="#{backing_app_ATBlobs1.inputFile1}"
    valueChangeListener="#{backing_app_ATBlobs1.fileUploaded}"
    id="inputFile1" columns="40"/>
    <af:commandButton text="commandButton 1"
    binding="#{backing_app_ATBlobs1.commandButton1}"
    id="commandButton1"/>
    The following is my code in the backing bean:
    public void fileUploaded(ValueChangeEvent event) {
    UploadedFile file = (UploadedFile)event.getNewValue();
    if (file != null && file.getLength() > 0) {
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage(JSFUtils.getStringFromBundle("srmain.srfileupload.success") +
    " " + file.getFilename() + " (" +
    file.getLength() + " bytes)");
    context.addMessage(event.getComponent().getClientId(context),
    message);
    FileInputStream fis;
    fis = null;
    try {
    fis = new FileInputStream((File)file);
    catch (FileNotFoundException ex)
    System.out.println("f2: Oops, FileNotFoundException caught");
    finally
    System.out.println("f2: finally block");
    PreparedStatement pstmt =
    cm.getCon().prepareStatement("INSERT INTO BLOBS (BLOB_ID, PROCUR_ID, PF_NUM, DOCUMEN, FILENAME_TXT) " +
    "VALUES ('" + BLOB_SEQUENCE.NEXTVAL + ",1, 2, ?, " + file.getFilename() + ")");
    pstmt.setBinaryStream(1, fis, (int)file.length());
    pstmt.executeUpdate();
    Following are the errors:
    Name cm Not Found
    Method getCon Not Found
    Method prepareStatement Not Found
    Method length() Not Found
    Name BLOB_SEQUENCE.NEXTVAL Not Found, BLOB_ID is sequentially generated.
    Exception Not handled: java.sql.SQLException for these lines:
    pstmt.setBinaryStream(1, fis, (int)file.length());
    pstmt.executeUpdate();
    I am not very sure about coding the values for the insert statement. Any help would be appreciated. Thanks!
    Lin

    Hi,
    I got some of the errors taken care of, but I have some questions.
    Below is my code:
    public void fileUploaded(ValueChangeEvent event) {
    // Add event code here...
    UploadedFile file = (UploadedFile) event.getNewValue();
    if (file != null)
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message = new FacesMessage( "Successfully uploaded file " + file.getFilename() + " (" + file.getLength() + " bytes)");
    context.addMessage(event.getComponent().getClientId(context), message);
    // Here's where we could call file.getInputStream()
    InputStream fis;
    fis = null;
    try {
    fis = file.getInputStream();
    catch (FileNotFoundException ex)
    System.out.println("FileNotFoundException caught");
    } catch (IOException e) {
    // TODO
    System.out.println("IOException caught");
    finally
    System.out.println("finally block");
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch (ClassNotFoundException ex) {     
    System.out.println("ClassNotFoundException caught");
    // DriverManager.registerDriver(new OracleDriver());
    try {
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@oradev2.tceq.state.tx.us:1521:sand3", "kding", "kd5469");
    PreparedStatement pstmt =
    conn.prepareStatement("INSERT INTO BLOBS (BLOB_ID, PROCUR_ID, PF_NUM, DOCUMEN, FILENAME_TXT) " +
    "VALUES (?,?,?,?,?)");
    int blob_id;
    blob_id = BLOB_SEQUENCE.NEXTVAL;
    String filename = file.getFilename();
    pstmt.setInt(1, blob_id);
    pstmt.setString(2, "1");
    pstmt.setString(3, "2");
    pstmt.setBinaryStream(4, fis, (int)file.getLength());
    pstmt.setString(5, filename);
    pstmt.executeUpdate();
    catch (SQLException e) {
    // TODO
    System.out.println("SQLException caught");
    I am unable to get the value for the blob_id which is sequentially generated. The error is in this line:
    blob_id = BLOB_SEQUENCE.NEXTVAL;
    Another question:
    Can someone tell me how to display variable in JDeveloper. I tried System.out.println - but I think this is for command line printing?
    Thanks for the assistance.
    Lin

  • How to copy uploaded blob to asset for AMS processing using PHP SDK

    I'm using Azure PHP SDK for Azure Media services and having problem with uploading large files (< 64 mb). So i tried using Blob service to upload as a chunk and commit it as a single file. It also works fine, and now media services won't directly take blob
    as a input. So i need to convert it into an Asset.
    I'm following the link https://msdn.microsoft.com/en-us/library/azure/jj933290.aspx which
    has example using .NET, is there a PHP sdk library support available for copying blob to asset. If yes please let me know the class and its methods or link.
    Please advice
    Mohanraj

    Hi Mohanraj,
    We recently had a fix for the problem you mentioned above:
    https://github.com/Azure/azure-sdk-for-php/commit/972e09c74308411602027280ededb3048b1e2fc4. We will try to release it asap but you can now try to upload by using this code pulled from dev branch.

  • Uploading Blobs using ADF 10.12 & 10.13

    Has anyone either,
    a) written an application using ADF using 10.12 or 10.13 that allows you to upload a file (e.g. JPG/Word Document) and store it in a database as a BLOB
    b) come across any tutorials/examples of this functionality?
    I have previously written applications that successfully retrieve and display JPG/GIFs that are stored as BLOBS in a database but I have never written the functionality to store them.
    I'd appreciate your thoughts/suggestions on this matter, thanks in advance
    David

    I wonder if you can accomplish to view back images which you have stored as blob in database via ADF 10.1.3. , eh!?
    I have uploaded image and stored as BLOB but couldn't find any way to display it in a page which is full of other records from database such as a student record with student image!?
    any idea?
    best regards...
    --barisk                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Upload blob to Content Services

    Hi
    Here's my problem... I have a blob in the E-Business Site iRecruitment table, IRC_DOCUMENTS. Using BPEL, I want to accept this blob and store it in Content Services using the filename in that table.
    I'm no java guru. Is this possible? How do I go about doing this?
    Thanks

    Hi Sancho
    1. When a new row is created in the iRecruitment table, I enqueue a message containing the BLOB and other data. In my BPEL process, I have a partner link that monitors and dequeues the message from the queue, then variables are assigned, which are read by a simple piece of embeded java code.
    2. This embeded java then creates a new folder in Content Services. So far so good. What I want to do next is to create a file in this new folder with the data from the BLOB. This is what I can't do yet, as I can't find the right documentation describing how this could be done.
    3. The requirements do not require me to maintain a link in iRecruitment (but who knows, that might change). Once the file is created (and there may be multiple files depending on the number rows read from the iRecruitement table, so I guess multiple enqueues), the process ends.
    Cheers
    Paul

  • How to Upload a PDF file into BLOB column in a table using Forms 9i

    Can anyone tell me how to upload a PDF file from client system using File dialog window and store its content in BLOB column in a table. The file to be uploaded will be in client side.

    Hi,
    please, search a bit on the forum before do a question:
    Just searching by "upload blob pdf" ...
    How to batch upload PDF files into database BLOB
    Regards,
    Jose.

  • PHP 5 Code to Upload and Retrieve an Image (aka BLOB) with Oracle

    I keep being asked about BLOBs. For posterity, here is my example updated
    to use the new PHP 5 OCI8 function names, and using bind variables for the BLOB id.
    -- cj
    <?php
    // Sample form to upload and insert an image into an ORACLE BLOB
    // column using PHP 5's OCI8 API. 
    // Note: Uses the new PHP 5 names for OCI8 functions.
    // Before running this script, execute these statements in SQL*Plus:
    //   drop table btab;
    //   create table btab (blobid number, blobdata blob);
    // This example uploads an image file and inserts it into a BLOB
    // column.  The image is retrieved back from the column and displayed.
    // Make sure there is no whitespace before "<?php" else the wrong HTTP
    // header will be sent and the image won't display properly.
    // Make sure php.ini's value for upload_max_filesize is large enough
    // for the largest lob to be uploaded.
    // Tested with Zend Core for Oracle 1.3 (i.e. PHP 5.0.5) with Oracle 10.2
    // Based on a sample originally found in
    //     http://www.php.net/manual/en/function.ocinewdescriptor.php
    $myblobid = 1;  // should really be a unique id e.g. a sequence number
    define("ORA_CON_UN", "hr");             // username
    define("ORA_CON_PW", "hr");             // password
    define("ORA_CON_DB", "//localhost/XE"); // connection string
    if (!isset($_FILES['lob_upload'])) {
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"
       enctype="multipart/form-data">
    Image filename: <input type="file" name="lob_upload">
    <input type="submit" value="Upload">
    </form>
    <?php
    else {
      $conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);
      // Delete any existing BLOB so the query at the bottom
      // displays the new data
      $query = 'DELETE FROM BTAB WHERE BLOBID = :MYBLOBID';
      $stmt = oci_parse ($conn, $query);
      oci_bind_by_name($stmt, ':MYBLOBID', $myblobid);
      $e = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS);
      if (!$e) {
        die;
      oci_free_statement($stmt);
      // Insert the BLOB from PHP's tempory upload area
      $lob = oci_new_descriptor($conn, OCI_D_LOB);
      $stmt = oci_parse($conn, 'INSERT INTO BTAB (BLOBID, BLOBDATA) '
             .'VALUES(:MYBLOBID, EMPTY_BLOB()) RETURNING BLOBDATA INTO :BLOBDATA');
      oci_bind_by_name($stmt, ':MYBLOBID', $myblobid);
      oci_bind_by_name($stmt, ':BLOBDATA', $lob, -1, OCI_B_BLOB);
      oci_execute($stmt, OCI_DEFAULT);
      // The function $lob->savefile(...) reads from the uploaded file.
      // If the data was already in a PHP variable $myv, the
      // $lob->save($myv) function could be used instead.
      if ($lob->savefile($_FILES['lob_upload']['tmp_name'])) {
        oci_commit($conn);
      else {
        echo "Couldn't upload Blob\n";
      $lob->free();
      oci_free_statement($stmt);
      // Now query the uploaded BLOB and display it
      $query = 'SELECT BLOBDATA FROM BTAB WHERE BLOBID = :MYBLOBID';
      $stmt = oci_parse ($conn, $query);
      oci_bind_by_name($stmt, ':MYBLOBID', $myblobid);
      oci_execute($stmt, OCI_DEFAULT);
      $arr = oci_fetch_assoc($stmt);
      $result = $arr['BLOBDATA']->load();
      // If any text (or whitespace!) is printed before this header is sent,
      // the text won't be displayed and the image won't display properly.
      // Comment out this line to see the text and debug such a problem.
      header("Content-type: image/JPEG");
      echo $result;
      oci_free_statement($stmt);
      oci_close($conn); // log off
    ?>

    I am using oracle 10g [10.2.0.1.0] and PHP 4.3.9 with Apache.
    I tried my best to change the old functions names for example(oci_fetch)
    to the new (OCIFetch),i works every where, but i could not find the corresponded functions of (oci_fetch_assoc) that's why i can not see my BLOBS at all!
    Can some help me please, to know where are corresponded functions of oracle 8 to oracle 10g?
    Exactly here is my problem:
    $query = 'SELECT BLOBDATA FROM BTAB WHERE BLOBID = :MYBLOBID';
    $stmt = ociparse ($conn, $query);
    OCIBindByName($stmt, ':MYBLOBID', $myblobid);
    ociexecute($stmt, OCIDEFAULT);
    $arr = oci_fetch_assoc($stmt);
    // OCIFetchAssoc, OCIFetch, OCI_ASSOC ... nothing works-> Fatal error: Call to undefined function:
    $result = $arr['BLOBDATA']->load();
    What should i do?
    Thanky very much.

  • Blob Upload dosent work.

    First my english is very bad. Iam from germany and the problem i have cant fix in forums in germany.
    so, please help me...
    I have generate a pdf file that i must put in a oracle BLOB field.
    Is Oracle 8
    here is the code :
    <?PHP
    $lob_upload="a.pdf";
    session_start();
    $conn = OCILogon('secret','secret','secret');
    $lob = OCINewDescriptor($conn, OCI_D_LOB);
    $stmt = OCIParse($conn,"insert into \"tblArchiv\" (\"AR_Objekt\")
    values(EMPTY_BLOB()) returning \"AR_Objekt\" into :the_blob");
    OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB);
    OCIExecute($stmt, OCI_DEFAULT);
    if($lob->savefile($lob_upload)){
    OCICommit($conn);
    echo "Blob successfully uploaded\n";
    }else{
    echo "Couldn't upload Blob\n";
    OCIFreeDesc($lob);
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>
    This code generate a new entry. but the blob field ist empty.
    Please help
    Werner

    Now i have found a sample code on Oracle side :
    <?php
    // Sample form to upload and insert data into an ORACLE CLOB column
    // using PHP's Oracle 8 API.
    // Based on http://www.php.net/manual/en/function.oci-new-descriptor.php
    // modified to work on CLOBs and use register_globals = Off.
    // Before running this script, execute these statements in SQL*Plus:
    // drop table myclobtab;
    // create table myclobtab (c1 number, c2 clob);
    // Tested with PHP 4.3.3 against Oracle 9.2
    if (!isset($_FILES['lob_upload'])) {
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
    Upload file: <input type="file" name="lob_upload">
    <input type="submit" value="Upload">
    </form>
    <?php
    else {
    $myid = 1; // should really be a unique id e.g. a sequence number
    $conn = OCILogon('secret', 'secret', 'secret');
    // Delete any existing CLOB so the query at the bottom
    // displays the new data
    #$query = 'DELETE FROM MYCLOBTAB';
    #$stmt = OCIParse ($conn, $query);
    #OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);
    #OCIFreeStatement($stmt);
    // Insert the CLOB from PHP's temporary upload area
    $lob = OCINewDescriptor($conn, OCI_D_LOB);
    $stmt = OCIParse($conn, "INSERT INTO \"tblArchiv\" (\"AR_Objekt\") VALUES(EMPTY_BLOB()) RETURNING \"AR_Objekt\" INTO :C2");
    OCIBindByName($stmt, ':C2', $lob, -1, OCI_B_BLOB);
    OCIExecute($stmt, OCI_DEFAULT);
    // The function $lob->savefile(...) reads from the uploaded file.
    // If the data was already in a PHP variable $myv, the
    // $lob->save($myv) function could be used instead.
    if ($lob->savefile($_FILES['lob_upload']['tmp_name'])) {
    OCICommit($conn);
    echo "CLOB successfully uploaded\n";
    else {
    echo "Could not upload CLOB\n";
    $lob->free();
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>
    This code runs good.
    But. The PDF File is on the server right now.
    So i change the code like this :
    <?php
    $myid = 1; // should really be a unique id e.g. a sequence number
    $conn = OCILogon('secret', 'secret', 'secret');
    // Delete any existing CLOB so the query at the bottom
    // displays the new data
    #$query = 'DELETE FROM MYCLOBTAB';
    #$stmt = OCIParse ($conn, $query);
    #OCIExecute($stmt, OCI_COMMIT_ON_SUCCESS);
    #OCIFreeStatement($stmt);
    // Insert the CLOB from PHP's temporary upload area
    $lob = OCINewDescriptor($conn, OCI_D_LOB);
    $stmt = OCIParse($conn, "INSERT INTO \"tblArchiv\" (\"AR_Objekt\") VALUES(EMPTY_BLOB()) RETURNING \"AR_Objekt\" INTO :C2");
    OCIBindByName($stmt, ':C2', $lob, -1, OCI_B_BLOB);
    OCIExecute($stmt, OCI_DEFAULT);
    // The function $lob->savefile(...) reads from the uploaded file.
    // If the data was already in a PHP variable $myv, the
    // $lob->save($myv) function could be used instead.
              $form_data="a.pdf";
              $data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));
              if ($lob->save($data)) {
    OCICommit($conn);
    echo "CLOB successfully uploaded\n";
    else {
    echo "Could not upload CLOB\n";
    $lob->free();
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>
    This code have the same problem. It inserted an new entry but the blobfield is empty.
    what is the mistake i made ?
    again : my english is very bad sorry.
    thanks
    Werner

  • Downloading BLOB from a table.

    Hello,
    First I want to say thatnks for such a great tool like HTMLDB.
    Question is:
    How do I download BLOB from a table. What I am trying to do is. I am uploading files to a default HTMLDB location (wwv_flow_file_objects$) and moving the records to different table (delete file from wwv_file_objects$). Then I would like to be able to download that blobs from a DB by following some link. And I need it to be secure, user have to authenticate to do it. I got to the point where I created process (before header) to download the file. But I am having hard time passing some variables to that process in URL. Can some one advice me on the best practice of doing it. And also if it is a right thing to use before header process to put my own header and start uploading blob in html db. The main reason I do not whant to use DAD for that is simple security issue and ability of storing of the BLOBs only in one table. I prefer to upload it to a temporary location and then move it to other table(s). Then I need to be able to retriev the files back from those tables without moving them around.
    Any help is greatly appriciated

    i think i see what you're asking, but i'll step through the pieces just to make sure i cover your issue:
    it sounds as if you have a procedure that successfully calls wpg_docload.download_file to get your blob out of your images table. for this explanation, lets just say your images table has the same table structure as wwv_flow_files created with something like...
    create table myfiles as select * from wwv_flow_files where rownum < 3;
    ....and let's say your download proc that passed the blob from your myfiles table to wpg_docload.download_file looked something like...
    create or replace procedure getmyfile(
    p_id in varchar2,
    p_mime_type in varchar2 default null)
    as
    l_lob blob;
    l_mimetype varchar2(48);
    l_mime_charset varchar2(255);
    l_filename varchar2(400);
    begin
    select mime_type, blob_content, filename, file_charset
    into l_mimetype, l_lob, l_filename, l_mime_charset
    from myfiles
    where id = p_id;
    if l_mime_charset is not null then
    owa_util.mime_header( l_mimetype, FALSE, l_mime_charset );
    else
    owa_util.mime_header( l_mimetype, FALSE );
    end if;
    htp.p('Content-length: ' || dbms_lob.getlength( l_lob ));
    htp.p('Content-Disposition: attachment; filename="' ||
    wwv_flow_utilities.escape_url( p_url => l_filename, p_url_charset => 'utf-8') || '"');
    owa_util.http_header_close;
    wpg_docload.download_file( l_lob );
    end;
    ...then it sounds as if this is where you start running into issues. to be able to call this procedure from the url, you'd have to grant execute on your getmyfile proc to the db user that your modplsql DAD uses to access your db. once that user was given access to run getmyfile, you could access your files in myfiles by calling a URL like...
    http://myserver.com/pls/mydad/myschema.getmyfile?p_id=1005529367869246
    ...where p_id is the unique id associated with your blob in getmyfiles (you could, of course, use whatever method you want to uniquely identify that file and adjust your select-into statement w/in your getmyfile procedure). so that's all fine and dandy, but it sounds as if you want users to have to authenticate into your html db application before they can access a blob in your images table. it also sounds as if you're on the right track to do so by putting your procedure call in a before_header html db process. you could quite easily call your getmyfile procedure in such an html db pl/sql before_header process with something like...
    begin
    getmyfile (p_id => 1008411584930314);
    end;
    ...which would cause your page to just show the blob associated with the id you passed to getmyfile. because you're now accessing your blob table through html db parsing as your application schema owner, you'd no longer need to grant execute on getmyfile to your modplsql DAD's db user. that eliminates most of the security hole to which you were referring. now that you're calling getmyfile from w/in an html db process, you can take advantage of all the other html db perks such as applying conditions and an authorization scheme to the html db process to really lock things down. finally, you asked about firing your process before_header versus other firing points. before_header is a good way to go, but if you really wanted to execute other procedural logic on your page before showing the blob (and you didn't want to implement that code as before_header processes that fire sequentially before your getmyfile call),you could just throw an htp.init in right before your getmyfile call to clear out your http buffer like so...
    begin
    htp.init;
    getmyfile (p_id => 1008411584930314);
    end;
    ...hope this helps,
    raj

Maybe you are looking for

  • Valid Apple ID but not an iCloud account?

    I have valid Apple ID/password. Trying to setup iCloud and after downloading necesary files, etc. and attempting to setup I receive iCloud sign in window, but when I attempt to sign in it states "This is valid Apple ID but is not iCloud account." How

  • Update of shipping condition in a sales order

    Hi All! I have a sales order where the sold-to-party and the ship-to-party are the same (from the customer master data). At header level, in the shipment condition field of the Shipping tab, I have the value from the Sold-to-party  master data. If i

  • Connecting XBox 360 Live to Verizon netbook

    I purchased an XBox 360 Live for my son for Christmas.  I cannot get it to connect. We originally had Verizon Wireless Broadband w/ an internal modem. I went and purchased a Verizon USB760 to get service and also a Cradlepoint Router from Best Buy. N

  • JAVA BEANSHELL EXCEPTION HANDLING

    Hi still new to ODI I have created a java beanshell script in ODI which calls a simple java class, cars, then sets the no of seats to a value designed to raise an exception. Exception raised but procedure works OK, How can I register the fact that it

  • Billing shows double charge!!!

    I bought for 500 coins to buy Line sticker, but bill shows 2 time buying. I would like to turn one of them.