4

I'm trying to Upload an Image to create a Document using Angular File Upload (https://github.com/danialfarid/ng-file-upload)

From this link : Upload functionality in visualforce page I found RemoteAction method, but I'm not sure how to get the ContentOfFile in base64 and also, I was wondering if we can use AngularFileUpload to upload the image which gives support to non-html5 browsers too.

Thanks Surya

2

1 Answer 1

3

Apex code for saving the chunks of file.

​public static String upload(String folderId, String documentId, String fileName, String base64BlobValue) {
        if(documentId == '' || documentId == null) {
            Document document = new Document(Name=fileName, FolderId=folderId, Body=EncodingUtil.Base64Decode(base64BlobValue), IsPublic=true);
            insert document;

            return document.Id;

        } else {

            Document document = [select Id, Body from Document where Id = :documentId];
            update new Document(Id = documentId, Body = EncodingUtil.Base64Decode(EncodingUtil.Base64Encode(document.Body) + base64BlobValue));

            return documentId;
        }
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .