Android - Upload Image in a Container

String connectionString = "DefaultEndpointsProtocol=https;AccountName=StorageAccountName;AccountKey=StorageAccountKey"
CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);
                        // Create the blob client
                        CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
                        // Get a reference to a container
                        // The container name must be lower case
                        CloudBlobContainer container = blobClient.getContainerReference("images");
                        // Create the container if it does not exist
                        container.createIfNotExists();
                        // Create a permissions object
                        BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
                        // Include public access in the permissions object
                        containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
                        // Set the permissions on the container
                        container.uploadPermissions(containerPermissions);
                        // Create or overwrite the "myimage.jpg" blob with contents from a local file
                        CloudBlockBlob blob = container.getBlockBlobReference("myimageYdolo.jpg");
                        File source = new File(currImageURI.toString());
                        blob.upload(new FileInputStream(source), source.length());
 I have used the above code to upload image in a storage container in azure from android. It throws the error on "// Create the blob client" line. some java.lang.verifyError. I have searched to solve this error but i can't find any solution.
                                                            

Hi Veerasuthan,
For this issue, I suggest you could try the code below.
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.*;
public class BlobSample {
public static final String storageConnectionString =
"DefaultEndpointsProtocol=http;"
+ "AccountName=your_account_name;"
+ "AccountKey= your_account_key";
public static void main(String[] args) {
CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient serviceClient = account.createCloudBlobClient();
// Container name must be lower case.
CloudBlobContainer container = serviceClient.getContainerReference("myimages");
container.createIfNotExists();
Aslo, you could refer to this code sample (https://github.com/Azure/azure-storage-java). Please try it.
Any results, please let me know free.
Regards,
Will
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to upload image in windows azure mobile service from android?

    I am new in android I am using windows azure mobile service and I am Inserting Text data successfully but now I want to Upload Image in windows azure mobile service. I know its is possible by Azure Storage I have seen this chrisrisner post but
    its confusing can anyone tell me simple step by step process to save image in windows azure mobile service.
    I will be Very Grateful for you. its very urgent

    Hello Nitesh,
    Saving an image into Azure Mobile Services doesn't scale very well and it's not recommended. It's recommended to use Azure Blob Storage for blob storage. It's cheaper and can store larger files.
    You can definitely use both Azure Mobile Services and Blob Storage together by saving the name of the image in your Mobile Services table and storing the actual file in the Blob storage. This way when you need to retrieve the actual image, you would retrieve
    it by it's name from Blob storage.
    Here's a MSDN article that explains how to use
    Azure Blob Storage.
    Let me know if this helps.
    Abdulwahab Suleiman

  • How to upload image to the progrogram...

    I am trying to upload the image to the function module but it says the "sunset.jpg" is feild unkonwn it is not defined by the data...
    and when i am passing this image stuff at the runtime... it gives me the memory dum.. would you like to help me... i am creating a splash screen with this code....
    i am giving you the code below...
    Regards
    Naim
    Code listing for function: ZJNC_START_SPLASH
    Description: Show Splash at Start
    FUNCTION zjnc_start_splash.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(IMAGEFILE) TYPE  C DEFAULT 'THANKS.JPG'
    *"     REFERENCE(WIDTH) TYPE  I DEFAULT 415
    *"     REFERENCE(HEIGHT) TYPE  I DEFAULT 274
    *"     REFERENCE(TIMEOUT) TYPE  I DEFAULT 3
    *"     REFERENCE(CALLBACK) TYPE  C
          Global data declarations
      MOVE imagefile TO g_name.
      MOVE width TO picwidth.
      MOVE height TO picheight.
      MOVE timeout TO pictimeout.
      MOVE callback TO piccallback.
      TRANSLATE piccallback TO UPPER CASE.
      PERFORM getpicurl.
      CALL SCREEN 0806.
    ENDFUNCTION.
    Code listing for function: ZJNC_END_SPLASH
    Description: Show Splash at End
    FUNCTION ZJNC_END_SPLASH.
    ""Local interface:
    *"  IMPORTING
    *"     REFERENCE(IMAGEFILE) TYPE  C DEFAULT 'THANKS.JPG'
    *"     REFERENCE(WIDTH) TYPE  I DEFAULT 415
    *"     REFERENCE(HEIGHT) TYPE  I DEFAULT 274
    *"     REFERENCE(TIMEOUT) TYPE  I DEFAULT 3
          Global data declarations
      MOVE imagefile TO g_name.
      MOVE width TO picwidth.
      MOVE height TO picheight.
      MOVE timeout TO pictimeout.
      PERFORM getpicurl.
      CALL SCREEN 2009.
    ENDFUNCTION.
    Code listing for: LZUTILTOP
    TOP level Include of Function Group ZUTIL
    Author Jayanta Narayan Choudhuri
            Flat 302
            395 Jodhpur Park
            Kolkata 700 068
          Email [email protected]
          URL:  http://www.geocities.com/ojnc
    FUNCTION-POOL zutil.                        "MESSAGE-ID ..
    TYPE-POOLS: abap.
    DATA: graphic_url(255),
          g_result   TYPE i,
          g_linesz   TYPE i,
          g_filesz   TYPE i,
          g_name(100).
    TYPES: t_graphic_line(256) TYPE x.
    DATA: graphic_line TYPE t_graphic_line,
          graphic_table TYPE TABLE OF t_graphic_line.
    DATA: picwidth        TYPE i,
          picheight       TYPE i,
          pictimeout      TYPE i,
          piccallback(60) TYPE c,
          first           TYPE boolean.
          CLASS ZCL_ES_SPLASH_SCREEN  DEFINITION
    CLASS zcl_es_splash_screen DEFINITION.
      PUBLIC SECTION.
        EVENTS on_close.
        METHODS constructor
          IMPORTING
            !i_num_secs  TYPE i DEFAULT 5
            !i_url       TYPE c
            !i_width     TYPE i
            !i_height    TYPE i.
      PROTECTED SECTION.
        METHODS handle_end_of_timer
          FOR EVENT finished OF cl_gui_timer.
      PRIVATE SECTION.
        DATA container TYPE REF TO cl_gui_dialogbox_container.
        DATA image     TYPE REF TO cl_gui_picture.
        DATA timer     TYPE REF TO cl_gui_timer.
    ENDCLASS.                    "ZCL_ES_SPLASH_SCREEN  DEFINITION
    CLASS ZCL_ES_SPLASH_SCREEN IMPLEMENTATION
    CLASS zcl_es_splash_screen IMPLEMENTATION.
      METHOD constructor.
        DATA: image_width     TYPE i,
              image_height    TYPE i.
        COMPUTE image_width  = i_width + 30.
        COMPUTE image_height = i_height + 50.
        CREATE OBJECT container
           EXPORTING
             width                       = 10
             height                      = 10
             top                         = 10
             left                        = 10
             name                        = 'DialogSplash'.
        CALL METHOD container->set_caption
          EXPORTING
            caption = g_name.
        CREATE OBJECT image
          EXPORTING
            parent = container.
        CALL METHOD image->load_picture_from_url
          EXPORTING
            url = i_url.
        image->set_display_mode( image->display_mode_normal_center ).
        cl_gui_cfw=>flush( ).
        container->set_metric( EXPORTING metric = image->metric_pixel ).
        DATA: myleft TYPE i,
              mytop  TYPE i.
        COMPUTE myleft = ( 800 - image_width ) / 2.
        COMPUTE mytop  = ( 600 - image_height ) / 2.
        IF myleft < 0.
          MOVE 0 TO myleft.
        ENDIF.
        IF mytop < 0.
          MOVE 0 TO mytop.
        ENDIF.
        container->set_position(
          EXPORTING
            height            = image_height
            left              = myleft
            top               = mytop
            width             = image_width ).
        cl_gui_cfw=>update_view( ).
        CREATE OBJECT timer.
        timer->interval = i_num_secs.
        SET HANDLER me->handle_end_of_timer FOR timer.
        timer->run( ).
        cl_gui_cfw=>flush( ).
      ENDMETHOD.                    "constructor
      METHOD handle_end_of_timer.
    I wanted NAMASTE to remain until JOB was complete.
       IF container IS NOT INITIAL.
         container->free( ).
         CLEAR container.
         FREE  container.
       ENDIF.
       IF timer IS NOT INITIAL.
         timer->free( ).
         CLEAR timer.
         FREE  timer.
       ENDIF.
       cl_gui_cfw=>flush( ).
        RAISE EVENT on_close.
      ENDMETHOD.                    "handle_end_of_timer
    ENDCLASS.                    "ZCL_ES_SPLASH_SCREEN  IMPLEMENTATION
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS: on_close FOR EVENT on_close OF zcl_es_splash_screen.
    ENDCLASS. "lcl_event_handler DEFINITION
    CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD on_close.
        IF sy-dynnr = 2009.
          LEAVE PROGRAM.
        ELSE.
          MOVE abap_false TO first.
          PERFORM (piccallback) IN PROGRAM (sy-cprog).
        ENDIF.
      ENDMETHOD. "on_close
    ENDCLASS. "lcl_event_handler IMPLEMENTATION
    DATA: splash TYPE REF TO zcl_es_splash_screen.
    *&      Module  STATUS_0806  OUTPUT
    MODULE status_0806 OUTPUT.
      IF first IS INITIAL.
        first = abap_true.
        SET TITLEBAR 'TITLE0806'.
        CREATE OBJECT splash
            EXPORTING
              i_num_secs = pictimeout
              i_url      = graphic_url
              i_width    = picwidth
              i_height   = picheight.
        SET HANDLER lcl_event_handler=>on_close FOR splash.
      ENDIF.
    ENDMODULE.                " STATUS_0806  OUTPUT
    *&      Module  STATUS_2009  OUTPUT
    MODULE status_2009 OUTPUT.
      IF first IS INITIAL.
        first = abap_true.
        SET TITLEBAR 'TITLE2009'.
        CREATE OBJECT splash
            EXPORTING
              i_num_secs = pictimeout
              i_url      = graphic_url
              i_width    = picwidth
              i_height   = picheight.
        SET HANDLER lcl_event_handler=>on_close FOR splash.
      ENDIF.
    ENDMODULE.                " STATUS_2009  OUTPUT
    *&      Form  getpicurl
    FORM getpicurl.
      OPEN DATASET g_name FOR INPUT IN BINARY MODE.
      REFRESH graphic_table.
      CLEAR   g_filesz.
      DO.
        CLEAR graphic_line.
        READ DATASET g_name INTO graphic_line ACTUAL LENGTH g_linesz.
        ADD g_linesz TO g_filesz.
        APPEND graphic_line TO graphic_table.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET g_name.
      CLEAR graphic_url.
      CALL FUNCTION 'DP_CREATE_URL'
        EXPORTING
          type                 = 'IMAGE'
          subtype              = 'GIF'
        TABLES
          data                 = graphic_table
        CHANGING
          url                  = graphic_url
        EXCEPTIONS
          dp_invalid_parameter = 1
          dp_error_put_table   = 2
          dp_error_general     = 3
          OTHERS               = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
    ENDFORM.                    "getpicurl

    Use this program..
    create object cust_container
      exporting
        container_name              = 'MYCONTAINER1'
    CREATE OBJECT split_container
      EXPORTING
       LINK_DYNNR        =
       LINK_REPID        =
       SHELLSTYLE        =
       LEFT              =
       TOP               =
        WIDTH             = 10
        HEIGHT            = 40
       METRIC            = cntl_metric_dynpro
       ALIGN             = 15
        PARENT            = cust_container
        ROWS              = 2
        COLUMNS           = 2
       NO_AUTODEF_PROGID_DYNNR =
       NAME              =
    EXCEPTIONS
       CNTL_ERROR        = 1
       CNTL_SYSTEM_ERROR = 2
       others            = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL METHOD split_container->get_container
      EXPORTING
        row       = 1
        column    = 1
      receiving
        container = cus_cont.
    create object picture
      exporting
        parent = cus_cont
    clear url.
    path = 'ZNAVEEN'.
    perform get_url using path.
    CALL METHOD picture->set_display_mode
        EXPORTING
          display_mode = cl_gui_picture=>display_mode_fit
    EXCEPTIONS
       ERROR        = 1
       others       = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Use this Perform to load Picture
    form get_url using  p_path.
    DATA query_table LIKE w3query OCCURS 1 WITH HEADER LINE.
      DATA html_table LIKE w3html OCCURS 1.
      DATA return_code LIKE  w3param-ret_code.
      DATA content_type LIKE  w3param-cont_type.
      DATA content_length LIKE  w3param-cont_len.
      DATA pic_data LIKE w3mime OCCURS 0.
      DATA pic_size TYPE i.
      REFRESH query_table.
      query_table-name = '_OBJECT_ID'.
      query_table-value = p_path.
      APPEND query_table.
      CALL FUNCTION 'WWW_GET_MIME_OBJECT'
           TABLES
                query_string        = query_table
                html                = html_table
                mime                = pic_data
           CHANGING
                return_code         = return_code
                content_type        = content_type
                content_length      = content_length
           EXCEPTIONS
                object_not_found    = 1
                parameter_not_found = 2
                OTHERS              = 3.
      IF sy-subrc = 0.
        pic_size = content_length.
      ENDIF.
      CALL FUNCTION 'DP_CREATE_URL'
           EXPORTING
                type     = 'image'
                subtype  = cndp_sap_tab_unknown
                size     = pic_size
                lifetime = cndp_lifetime_transaction
           TABLES
                data     = pic_data
           CHANGING
                url      = url
           EXCEPTIONS
                OTHERS   = 1.

  • The form field arguments.image did not contain a file.

    Hi there,
    I'm getting a strange error with a simple file upload and I
    can't figure it out for the life of me. It's odd, because old code
    I have written before has worked fine in this area, and I really
    honestly can't see where I am going wrong.
    First the error:
    The form field arguments.image did not contain a file.
    The error occurred in
    C:\ColdFusion8\wwwroot\red_roof_rentals\components\query.cfc: line
    37
    35 :
    36 : <!---<cftry>--->
    37 : <cffile action="upload"
    accept="image/jpg,image/jpeg,image/gif" filefield="arguments.image"
    nameconflict="overwrite"
    destination="#getDirectoryFromPath(getBaseTemplatePath())#\properties\">
    38 : <cfset variables.image = "#file.ServerFile#" />
    39 : <cfset variables.thumb = "thumb_#file.ServerFile#"
    />
    I have researched this and found other people have had the
    same problem - although please be aware that I do not beleive this
    to be an issue with whatever version of CF I am running. I have
    still not found an answer.
    I have one template with my form called
    "admin_create_property.cfm". When the form posts it invokes a CFC
    method that uploads the file and inserts stuff into the database.
    However, it dies at the file upload part with that bizzarre error.
    There are only two files working in this:
    admin_create_property.cfm
    query.cfc
    I will write the code out for these so you can see. Please
    see attached code. Please note that I have taken out as much
    irrelevant code as possible (html, doctypes etc etc).
    Any help with this would be greatly appreciated as I am
    absolutley stumped to be quite honest. I've heard people say it
    could be any of the following:
    1 - Need to use enctype="multipart/form-data" - which I DO
    2 - cffile filefield can't contain ## - which it DOESN'T
    3 - Inut type must be file - which it clearly is.
    Please please help, I feel stupid asking about this but I
    need you guys more than ever!
    Kind regards and thanks in advance,
    Mikey.

    I don't get what you mean as this is what I am doing.
    <cfinvokeargument name="image" value="#form.image#" />
    This takes the value of the image file field and passes it to
    the CFC as an argument.
    Am I doing something wrong with this? Sorry for my
    stupidness!
    Thanks for you help, further assistance would be greatly
    appreciated.
    EDIT: Interestingly enough, if I just use the tag on my
    "admin_create_property.cfm" page instead of using the CFC method
    like this...
    <cffile action="upload"
    accept="image/jpg,image/jpeg,image/gif" filefield="form.image"
    nameconflict="overwrite"
    destination="#getDirectoryFromPath(getBaseTemplatePath())#\properties\">
    It seems to upload the image just fine. Why then would this
    not work if all I am doing is simply passing to the CFC the value
    of the "form.image" as an argument so that the file upload can
    happen in my CFC instead of in the calling template??!
    It's really bizzarre.
    Mikey.

  • I previously uploaded images onto my desktop to work on in Lightroom 5.2. I worked on a few of the images days ago and just now getting back to them. My problem is I can only access the images I previously worked on and all the rest it says images not ava

    I previously uploaded images onto my desktop to work on in Lightroom 5.2. I worked on a few of the images days ago and just now getting back to them. My problem is I can only access the images I previously worked on and all the rest it says images not available but all the images are still right on my desktop.

    ... and all the rest it says images not available
    Normally this happens because you moved, renamed or deleted these photos (or the folders that contain them) outside of Lightroom. This is how to fix the problem: Adobe Lightroom - Find moved or missing files and folders

  • Embed a MIME image into a container

    Hi experts,
    I am trying to create a selection menu that is composed of several images as pushbuttons.
    I have implemented an initial solution uploading those images using SE78 transaction. But, it has the restriction of using images of a very low quality (256 colours). However, I upload again the image to the MIME repository object and in the preview I could see it correctly.
    So, is it possible to embed this MIME image into a container in a dynpro? I was reading several posts but I cannot create an example:
    My picture is a .PNG and is upload into path SAP/PUBLIC/.
    http://scn.sap.com/community/abap/blog/2013/08/05/pictures-from-mime-repository-in-html
    I’d really appreciate your help.
    Lots of thanks,
    Javier

    Please See this cod : He is in PBO.
    *&      Module  IMAGE  OUTPUT
    *       text
    MODULE image OUTPUT.
      DATA: lt_query         LIKE w3query OCCURS 1 WITH HEADER LINE,
             lt_html          LIKE w3html OCCURS 1,
             l_return         LIKE  w3param-ret_code,
             l_content_type   LIKE  w3param-cont_type,
             l_content_length LIKE  w3param-cont_len,
             lt_pic_data      LIKE w3mime OCCURS 0,
             l_pic_size       TYPE i,
             l_url(256)       TYPE c .
       IF v_container IS INITIAL.
         CREATE OBJECT v_container
           EXPORTING
             container_name = 'CONTAINER'.
         CREATE OBJECT v_image
           EXPORTING
             parent = v_container.
         lt_query-name = '_OBJECT_ID'.
         lt_query-value = 'ZLOGO_VIVO_CAIXA'.
         APPEND lt_query.
         CALL FUNCTION 'WWW_GET_MIME_OBJECT'
           TABLES
             query_string   = lt_query
             html           = lt_html
             mime           = lt_pic_data
           CHANGING
             return_code    = l_return
             content_type   = l_content_type
             content_length = l_content_length.
         IF l_return IS INITIAL.
           CALL FUNCTION 'DP_CREATE_URL'
             EXPORTING
               type     = 'image'
               subtype  = cndp_sap_tab_unknown
               size     = l_pic_size
               lifetime = cndp_lifetime_transaction
             TABLES
               data     = lt_pic_data
             CHANGING
               url      = l_url
             EXCEPTIONS
               OTHERS   = 1.
           CALL METHOD v_image->load_picture_from_url
             EXPORTING
               url = l_url.
         ENDIF.
       ENDIF.
    Hope helped you.
    ENDMODULE.                 " IMAGE  OUTPUT

  • User Uploaded Image won't display on Mac OSX

    I am experiencing something very strange with user uploaded
    images on Mac OSX, latest Debug Flash Player 9, Safari and Firefox
    2. Everything works fine on Windows (XP and Vista) on all major
    browsers.
    A user selects a local image to upload. The file gets
    uploaded to server, resampled, saved to a public location, and a
    response is sent back to the Flash Player in the form of a JSON
    object. The response contains the URL to the uploaded image on the
    server. The Flash Player downloads the image and adds the Loader to
    a sprite that is already on the stage. All appropriate events are
    fired. The progress events show that the image is downloading, and
    the complete and init events are both fired. Using the Charles Web
    debugging Proxy I can verify that everything is working correctly
    (upload and download), and no security violations are occuring.
    Charles even shows the actual image that gets downloaded. However,
    on Mac, the image doesn't display (stays blank, as if it's an empty
    sprite), whereas on PC/Windows the image displays fine.
    I have placed a crossdomain file in the appropriate location
    - even though it is never requested as I don't try to do anything
    with the image's bitmap data.
    Unfortunately, I haven't had a chance to create a new project
    to test this out in, but will do as soon as I can, and post a link.
    Any ideas?
    Many thanks,
    Shaun.

    We had a similar problem, maybe it is related to this (it was
    done in as2, but the real problem was outside flash)
    flash took an enormous time to display thumbs for a gallery
    of images.. and directly in ff on osx, the thumb (about 100x100 px)
    would load only half way.. and again wait for about half a minute
    or more.. and then display. In flash the thumb would remain blank
    until the loading was over.. that is for about half a minute or
    more.
    What this turned out to be, was that the php script on the
    server somehow returned header information that the image had the
    dimensions of the full-sized image. So after all the data for the
    thumb downloaded, the client (browser or flash) would just wait
    until a predefined timeout..
    Since you are resizing uploaded images I thought this could
    be one of the possible reasons, maybe the flash player for osx and
    for windows handle such "missing data" cases differently.

  • How to upload image using JSP

    hi,
    i am confronting a problem how to upload image from local PC to web server . I am using Tomcat 4.0
    please help me by sending code
    thanks

    Hi,
    Here is the solution for uploading images and displaying images. I am using struts with JSP, so this code has a Action and ActionForm class. You can put the same code in Java Beans or Servlet class to run it. This code has two JSP files - one for Upload (upload.jsp)and other for Image(image.jsp) display. It has a Servlet also to display the image. Here is the code file wise.
    Upload.jsp **********************************************************
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <html:html>
    <head>
    <title>New Page 1</title>
    </head>
    <body>
    <html:form action="uploadAction.do" enctype="multipart/form-data" method="POST">
    <p>File to upload   
    <html:file property="fileUpload" size="20"/></p>
    <p><html:submit value="Upload" property="upload"/></p>
    <p> </p>
    <p><html:img src="image.jsp"/></p>
    <p> </p>
    </html:form>
    </body>
    </html:html>
    Image.jsp*****************************************************************
    <jsp:useBean id="upload" class="uploadtest.uploadActionForm" scope="session">
    </jsp:useBean>
    <%
         byte[] rgb=(byte[])session.getAttribute("byte");
         request.setAttribute("byArr", rgb);
    %>
    <!--
    The image data is now on the request object.
    Forward the user to the showImage servlet.
    That servlet will process and display the image data contained on the request object.
    -->
    Image is<p>
    <jsp:forward page="/showimage" />
    Struts Action Class - UploadAction.java **************************************************
    import javax.servlet.http.*;
    import java.io.*;
    import org.apache.struts.upload.FormFile;
    import org.apache.struts.action.*;
    public class uploadAction extends Action {
    public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
    uploadActionForm upload = (uploadActionForm) actionForm;
    try {
    int size=upload.getFileUpload().getFileSize();
    //if (image != null) {
    byte[] byteArr = new byte[size];
    //Create an input stream to read the uploaded file.
    ByteArrayInputStream bytein = new ByteArrayInputStream(upload.getFileUpload().getFileData());
    // Load the input stream into the byte Array.
    bytein.read(byteArr);
    // Close the input stream.
    bytein.close();
    // Load the byte[] into the content field.
    upload.setContent(byteArr);
    HttpSession ses=httpServletRequest.getSession();
    ses.setAttribute("byte",byteArr);
    return actionMapping.findForward("success");
    } catch (Exception ex) {
    ex.printStackTrace();
    return actionMapping.findForward("success");
    Struts ActionForm class ---uploadActionForm.java***************************************************
    package uploadtest;
    import org.apache.struts.action.*;
    import org.apache.struts.upload.*;
    import javax.servlet.http.*;
    public class uploadActionForm extends ActionForm {
    private FormFile fileUpload;
    private byte[] content;
    public FormFile getFileUpload() {
    return fileUpload;
    public void setFileUpload(FormFile fileUpload) {
    this.fileUpload = fileUpload;
    public byte[] getContent()
    return content;
    public void setContent(byte[] theFile)
    this.content = theFile;
    public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
    /**@todo: finish this method, this is just the skeleton.*/
    return null;
    public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
    Servlet to display image --- ShowImage.java ********************************************************
    import java.io.*;
    import java.util.*;
    public class ShowImage extends HttpServlet {
    //Initialize global variables
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    byte[] rgb = (byte[]) request.getAttribute("byArr");
    if (rgb != null)
    response.setContentType("image/gif");
    OutputStream stream = response.getOutputStream();
    stream.write(rgb);
    else
    response.setContentType("text");
    response.getWriter().write("attribute byArr not found");
    This code will enable to to upload and display the image. If you know Struts, then you can write the Struts-Config.xml file by yourself. Other wise write to me, I will send you that. If you want to save the image in database, then you have to keep it as BLOB datatype is database. For database you need to send the byte array in the uploadAction.java file to database. Database will keep the image as binary.
    Thanks
    Amit

  • Upload image,file(zip,txt,word,excel...)

    how to upload image or file(zip,txt,word,excel,ppt and so on) to database,then show it by jsp page? Someone can give me a sample?

    there are some things to do:
    1) an HTML page (it can be generated via JSP or can be a plain HTML page) containing a form line this:
    2) a jsp or servlet that reads the file uploaded and writes it tio db
    3) a jsp that read from db and display the page
    it isn't complex, but quite long. Some suggestions:
    1)
    <form name="form1" action="..." method="post" enctype="multipart/form-data">
    <input type="file" name="file_name" value="">
    </form>
    2) You can use this library http://www.servlets.com/cos/index.html for getting the file. You can decide what to do about it (saving in the file system, in a db, ad so on). It is really a good library and well documented!
    3) set the content type of the result page appropriatly (see other threads in this forum about this topic!)
    -- Ivan

  • Uploading images from PE6

    I will learn this yet. Can anybody tell me how to upload images from PE6 to a stock photography web site.

    Hi dongieux!
    Thanks for posting.
    In the left margin of ImageBrowser EX, select the folder containing the images.  Then, hold the CTRL key and click on each image you want to upload to select it.  After they are selected, click on the Canon Image Gateway button at the time, then Upload Images.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Upload image and make thumbnail

    Is that possible for ADDT to upload and resize image and make a thumbnail at the same time?

    Hi chan15,
    that´s only possible with a Custom Trigger which contains custom PHP code to create a thumbnail from the uploaded image and store it in whatever folder.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • KMC WIKI 7.30 - Upload Image error

    Hello,
    if I try to upload an image I get this error:
    FreeMarker template error!
    Expression action.fieldErrors["Filedata"] is undefined on line 821, column 36 in template/global/image-picker.ftl.
    The problematic instruction:
    ==> list action.fieldErrors["Filedata"] as error [on line 821, column 29 in template/global/image-picker.ftl]
    Java backtrace for programmers:
    freemarker.core.InvalidReferenceException: Expression action.fieldErrors["Filedata"] is undefined on line 821, column 36 in template/global/image-picker.ftl.
    at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)

    See snote 1554787.
    But the Problem still exist. You cannot upload images and attach files, images and others to wiki pages.
    KMC-UI 1000.7.30.2.1.20110522175000
    KMC-WIKI 1000.7.30.2.1.20110518212000
    attachment
    Admin Error
    We're sorry but a serious error has occurred in the system.
    jive.error.log:
    [error] com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO WIK_AttachData (attachmentID, attachmentData) VALUES (?, EMPTY
    _BLOB())" contains the syntax error[s]: - 1:80 - SQL syntax error: the token "(" was not expected here
    com.jivesoftware.base.database.dao.DAOException: com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO WIK_AttachData (attachmentID, attachmentD
    ata) VALUES (?, EMPTY_BLOB())" contains the syntax error[s]: - 1:80 - SQL syntax error: the token "(" was not expected here
            at com.jivesoftware.community.impl.dao.DbAttachmentDAO.saveAttachmentData(DbAttachmentDAO.java:395)
            at com.jivesoftware.community.impl.DbAttachment.insert(DbAttachment.java:555)
            at com.jivesoftware.community.impl.DbAttachment.<init>(DbAttachment.java:93)
    upload image
    FreeMarker template error!
    Expression action.fieldErrors["Filedata"] is undefined on line 821, column 36 in template/global/image-picker.ftl.
    The problematic instruction:
    ==> list action.fieldErrors["Filedata"] as error [on line 821, column 29 in template/global/image-picker.ftl]
    Java backtrace for programmers:
    freemarker.core.InvalidReferenceException: Expression action.fieldErrors["Filedata"] is undefined on line 821, column 36 in template/global/image-picker.ftl.
         at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
         at freemarker.core.IteratorBlock.accept(IteratorBlock.java:93)
         at freemarker.core.Environment.visit(Environment.java:196)

  • Can not upload image of larger size in jsf

    i had some issues in file uploading. File uploading is working fine in my local machine and when i am using the www.mywebsite.com:8080/fileUpload.jsf
    but i can not upload images by using the following www.mywebsite.com/fileUpload.jsf
    Ie: without the port. I am using windows server and tomcat 5.5.27
    When i am trying to upload a bigger size image i am getting the following error
    I am using jsf(tomahawk)
    09:10:47,315 ERROR MultipartRequestWrapper:? - Exception while uploading file.
    org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. Socket read failed
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:384)
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:268)
    at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:85)
    at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:181)
    at org.apache.myfaces.context.servlet.RequestParameterMap.getAttribute(RequestParameterMap.java:42)
    at org.apache.myfaces.context.servlet.AbstractAttributeMap.get(AbstractAttributeMap.java:91)
    at org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getTreeStructureToRestore(HtmlResponseStateManager.java:159)
    at org.apache.myfaces.application.jsp.JspStateManagerImpl.getSequenceString(JspStateManagerImpl.java:260)
    at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure(JspStateManagerImpl.java:230)
    at org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:267)
    at org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:231)
    at org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:81)
    at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
    at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:100)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at com.zerone.rrs.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:100)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
    at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:444)
    at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:472)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
    at java.lang.Thread.run(Unknown Source)

    Never mind . problem solved after i restarted

  • Error message "This program cannot display the webpage when uploading images to Cafe Press

    I have had a Café Press shop for five years and except for sometimes being slow, no problems uploading images. Now, suddenly for 3 days I get the message "This program cannot display the webpage
    Most likely causes:
    • You are not connected to the Internet.
    • The website is encountering problems.
    • There might be a typing error in the address.
    What you can try:
    Check your Internet connection. Try visiting another website to make sure you are connected.
    Retype the address."
    I got the messsage about half way through the uploading of an image. People suggested using "firefox" instead of IE so I now get a similar error message from Firefox. I signed in, clicked on the image I wanted to upload and hit "upload" and get message as follows:
    Server not found
    Firefox can't find the server at members.cafepress.com.
    * Check the address for typing errors such as
    ww.example.com instead of
    [url=http://www.example.com]www.example.com[/url]
    * If you are unable to load any pages, check your computer's network connection.
    * If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
    None of this makes sense because I WAS connected to the internet (obviously) or I wouldn't have been able to sign in, go to my media basket, browse for the image and click "upload" and watch as the progress bar showed percentage of upload such as 20%, etc. and even went to 100% at times before giving me the error message. Plus I couldn't make a typing error since I wasn't typing anything but uploading an image. Any suggestions?
    Whatever your suggestion, I need step by step instructions as I am totally computer illiterate. I don't even know what a "proxy" is and don't know if I have a "firewall" as the message suggests. I have "Comodo" security and am using Windows XP.
    I contacted CP which was no help at all. All they did was tell me to clear my cache which I do after every session. Thanks
    Nancy
    http://www.cafepress.com/calendarflr

    Sounds like your desktop application is in fact running from
    a server. CHMs were identified as a security risk by Microsoft and
    are best suited to the user's PC.
    Click
    here for more information.

  • Simple upload image to amazon S3 winjs for windows phone 8.1?

    Hi
    Can behind simple upload image to amazon S3 winjs for windows phone 8.1?Thank

    Yes.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.
    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined
    objects and unknown namespaces.

Maybe you are looking for