dbr.upload - increment image name - File image.jpg already exists

(9 posts) (2 voices)

Tags:

No tags yet.

  1. maron, Member

    Hello.

    I have a report which I want to use an iphone to add an image to, via dbr.upload.

    However, I always get image.jpg exists after inserting the first image, how can I create an incremental counter on images with the same name so they don't overlap.

    I did try this in the upload procedure but it didn't work

    set in_file = concat(in_id, DATE_FORMAT(NOW(), '-%Y-%m-%d-%H-%i-%s-'), in_file);

  2. myDBR Team, Key Master

    There is an option, add_time, that you can use for this exact purpose.

    --
    myDBR Team

  3. maron, Member

    The add_time works fine when adding images from the photo library on ios. However when taking pictures directly into the form (an option in ios) it doesn't add the time, and the name is always image.jpg.

    On a sidenote it would be great if we could have copy paste support into the upload field as well, meaning, we could paste img data from clipboard (for example screenshots) - this would greatly enhance the current use case where we are using various data sources for inspection purposes, some are online and sometimes we have to go on site to photograph.

  4. myDBR Team, Key Master

    How does your form/report look like?

    --
    myDBR Team

  5. maron, Member


    declare _action varchar(45); if json_valid(inJson) and inJson ->> '$.action' is not null then
    set _action = inJson ->> '$.action';
    else
    set _action = '';
    end if; if _action = '' then select 'dbr.pageview';
    select inUUID as "uuid:"; -- Upload image to server side files
    select 'dbr.upload.options', 'noreplace', 1;
    select 'dbr.upload.options', 'add_time', 1;
    select 'dbr.upload.options', 'accepted_files', '.jpg,.jpeg,.png';
    select 'dbr.upload.options', 'title', 'Click here to upload node image';
    select 'dbr.upload','/path/to/dbr/user/MapImages','sp_DBR_upload_file', inUUID;
    select 'dummy'; select 'dbr.report', 'sp_DBR_nodes_history', '[form_action]', 'inJson=p_json';
    select 'dbr.form', 'json', 'inPostJson'; select 'dbr.form', 'start', 'my_form'; -- The form starts here
    select 'form_action', json_object(
    'uuid',
    inUUID,
    'action',
    'new_history'
    ) as p_json; select 'dbr.form', 'textarea', 'descr', 'Description:';
    select 'dummy'; select 'dbr.form', 'submit', 'Add new Node History';
    select 'dbr.form', 'end'; -- The form ends here
    select 'dummy'; elseif _action = 'new_history' then set @uuid = inJson ->> "$.uuid";
    set @in_descr = inPostJson ->> "$.in_descr"; select
    description into @is_descr_empty
    from AhaInfo.nodes_description
    where uuid = @uuid; if @is_descr_empty is null then
    update AhaInfo.nodes_description
    set description = CONCAT('[\"', REPLACE(@in_descr, 'user/', ''), '\"]')
    where uuid = @uuid;
    else
    update AhaInfo.nodes_description
    set description = CONCAT('[\"', replace(@in_descr, 'user/', ''), '\",', SUBSTRING(description, 2))
    where uuid = @uuid;
    end if; select 'dbr.text', 'History for node successfully added.';
    select 'dbr.text', ''; select 'dbr.pageview';
    select
    *
    from AhaInfo.nodes_description
    where uuid = @uuid; -- select 'dbr.report', 'sp_DBR_merchant_home_page', 'inJson=p_json';
    -- select 'dbr.button', 'Home Page';
    -- select json_object(
    -- 'action', ''
    -- ) as p_json; end if;

  6. myDBR Team, Key Master

    Thanks,
    we'll take a look at it.

    --
    myDBR Team

  7. maron, Member

    Thanks. That would help a lot on our side.

  8. myDBR Team, Key Master

    For iPhone paste you could do following.

    Create a dummy input field so the user can trigger the paste action.

    select 'dbr.html', '<input id="paste" placeholder="Paste here">';

    Catch the paste event on the page and add the clipboard content as a file to be uploaded:

    select 'dbr.javascript', "
    document.getElementById('paste').onpaste = function(event){
    const items = (event.clipboardData || event.originalEvent.clipboardData).items;
    for (const item of items) {
    if (item.kind === 'file') {
    $('.dz_upload')[0].dropzone.addFile(item.getAsFile())
    }
    }
    }
    ";

    As for the add_time not working, could you try running the updater and try again. If it does not work, could you create a sample code that shows the option not working. You can use the support email for this.

    --
    myDBR Team

  9. maron, Member

    Perfect - works well - thanks


Reply

You must log in to post.