Activity Forums Salesforce® Discussions Access Camera in Salesforce1

  • Piyush

    Member
    April 26, 2016 at 8:07 am
  • Parul

    Member
    September 20, 2018 at 1:07 am

    Hi,

    Controller:-

    public class CameraAccess{
    public ContentVersion cont {get;set;}

    public CameraAccess() {
    cont = new ContentVersion();
    }

    public PageReference saveFile()
    {
    //PathOnClient is Mandatory
    cont.PathOnClient = cont.title;

    //By default Origin value is "C" that means Content must be enabled in Org, so we need to explicitly set Origin as H
    cont.Origin = 'H';
    insert cont;

    //redirect to path where file is saved
    return new PageReference('/'+cont.id);
    }
    }

    Visualforce Page:-

    <apex:page controller="CameraAccess" standardStylesheets="false" showHeader="false">

    <apex:stylesheet value="{!URLFOR($Resource.BootStrap3, '/bootstrap-3.1.1-dist/css/bootstrap.css')}" />
    <div class="container">
    <div class="row clearfix">
    <div class="col-md-12 column">
    <div class="jumbotron">
    <h1> Camera Access in Visualforce using HTML 5 </h1>
    <a href="https://jitendrazaa.com">https://jitendrazaa.com</a&gt;
    </div>
    <div class="panel panel-warning">
    <div class="panel-heading">
    <apex:form>
    <p>
    <apex:inputFile value="{!cont.VersionData}" accept="image/*;capture=camera" filename="{!cont.Title}" />
    </p>

    <p>
    <apex:commandButton StyleClass="btn btn-danger" action="{!saveFile}" value="Save File" />
    </p>
    </apex:form>
    </div>
    </div>
    </div>
    </div>
    </div>

    </apex:page>

  • shariq

    Member
    September 20, 2018 at 7:28 pm

    Hi,

    You can search on  app exchange, I think there is a feature regarding it.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos