A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Hot answers tagged

19

Use the ajax toolkit to perform the upload from javascript. This way you avoid apex heap size limit. I've done it and successfully uploaded files up to ~35 mb in size. 1) Reference the ajax toolkit in your visualforce page. <apex:includeScript value="../../soap/ajax/26.0/connection.js" /> 2) Write javascript to upload to server (in this case its ...


15

No, the "contents" of the elements in a change set will reflect the most recent version of the file until it is "uploaded". That is, if you add an Apex Class to a change set, change the class and then upload the change set, the modified version will be deployed. You can see exactly what is in the changeset files by clicking the name to "view" the file, you ...


10

I don't have specific code to share, but if HTML5 is a possibility then converting the image to a Canvas tag might be able to do this. You can manipulate the canvas and then convert the result into a base64 string.


9

UPDATE The component is now supported for guest users with Spring '19. Let Community Guest Users Upload Files release notes. Promote file sharing in your communities. Let guest users upload files using the lightning:fileUpload component. From documentation for the component: By default, guest users can’t upload files. You can enable the org ...


8

Here's a (mostly) client-side version that should run on all modern browsers (NOTE: Modern does not include IE8 or lower). Does not use view state, and accepts any image type the browser does. Error checking is sparse, as this is only a demonstration. This uses a drag-and-drop interface, but you could also build a traditional file selector interface (not ...


8

I'm not aware of a way to manipulate images within Apex. This would be beyond the capabilities of Apex. One approach however could be to push the uploaded image out to an external process to handle the resizing. After the file has been uploaded push the file to a third party web service using a apex call out and have the web service return the resized image. ...


8

Yes that is correct, governor limits will apply to each batch, which in turn is decided by the batch size set on the dataloader. The dataloader will chunk the records from your csv file in batches of the number of records you've specified, and hence the governor limits are therefore distributed.


8

There are several mechanisms that allow you to upload files into SFDC. Rich Text Area is not the proper place where you should store these (I don't think its even possible either). Attachments Attachments are linked directly to a SOBject via the ID of the record. (Attachment.ParentId) and show as a related list at the bottom of the Detail Record. ...


7

Good question, I personally would not try to handle this in the client, it's to fragile an environment, better to upload this file and handle at the server side. Or consider adjusting your requirements / user expectations to fit Salesforce Data Loader tools, see my summary below. Client Side Client Library and Communications. You can find likely find a ...


7

Looks like you found the solution, but for other folks, I've seen this error occur in three different ways. Calling String.replace() on very large strings (somewhere around 500k from memory, but it varied based on heap usage). This is extra confusing since String.replace() doesn't support regexes. The solution is to chunk up the string into smaller chunks ...


7

You can just create an Attachment on the Account. It should work the same way as creating an object in Salesforce. Some important considerations: The API sends and receives the binary file attachment data encoded as a base64Binary data type. Prior to creating a record, client applications must encode the binary attachment data as base64. Upon receiving a ...


7

It looks like the CSV file has the dates in mm/dd/yyyy format rather than dd/mm/yyyy. Hence the invalid date exception with the 31st month. This will work: date parsedDate = date.parse('31/5/2013'); This will fail with "System.TypeException: Invalid date: 5/31/2013" date parsedDate = date.parse('5/31/2013'); From the Date.parse methods docs: ...


7

There isn't anything specific to Documents. They're treated just like any other sObject, so post to that objects endpoint, i.e. /services/data/v29.0/sobjects/Document/ And include pass a json representation of the object. Note you'll need to base64 encode the body (not shown in example). { "folderid": "00l50000000thwt", "body": "hello world", ...


7

Adam Torman's answer to a somewhat related (but not entirely) question notes: We do intentionally block the setting of parent permissions if it's a standard object By granting any access to a custom object that is M/D to a standard object, that necessitates giving access to that standard object as well. Managed package permission sets can't grant any ...


7

Realistically, you're not going to be able to do this, for a variety of reasons: Heap Limits The only context that can even store 20 MB of data in RAM is Email Services. That means you'd have to kick off an email to Salesforce just to get your code to have enough memory to load your file in memory, much less have a chance of doing anything. Batch Apex, ...


6

In my experience, It's pretty difficult, as you need to be able to base64encode the file before it's sent to the server (this can accomplish in some browsers Firefox, Chrome, Safari? Probably not IE.) Also, to get VisualForce to properly encode the 'form-data' that is being submitted to the server you need to create a VF form that points directly to a 'File ...


6

I had a similar need recently and ended up using HTML 5 canvas for this purpose based on what joshbirk said. It turned out to be pretty straight forward. Here is a link to working demo: http://free-12415f14c3a-124e539428a-12ea33928a3.mysandbox.cs11.force.com/ResizeImage and the github link https://github.com/bkhakurel/ImageResizeApex


6

I would recommend using chatter files related to the record rather than attachments as chatter files have a number of features that attachments lack. To upload a file and relate it to a record you use a feeditem with the following required fields. ContentData: base64 encoded file ContentFileName: file name ParentId: account/opportunity ID Type: '...


6

You will need to check the Content-Type of attachment loaded String contenttype=Attachment.contenttype; if(contenttype=='image/jpeg' || contenttype=='image/png' || contenttype=='image/gif' || contenttype=='image/jpg' ){ }


6

lightning:input is still beta, and has quite a few problems. It doesn't even currently have a documented files attribute at the moment. As far as I'm aware, you still need to use a native input element of type "file".


5

A common problem would be leading white space, try using trim() site.Estimated_Value__c = decimal.valueOf(inputsitevalues[9].trim());


5

I would like to recommend ready to use Salesforce Appexchange Native App Cloud Drop in order to store any number and size of files that can be associated with any salesforce object. Cloud Drop is one of a smart and excellent native app available which integrated Salesforce with Rackspace. Please check the following link for more information: https://...


5

The 'File Size Limits in Salesforce' help topic indicates that the following support 2GB. Files Tab and Chatter Salesforce CRM Content Feed Attachments That said, getting this size of data file in programatically reduces this to 10MB for Visualforce / Apex. Apex is going to be the limiting factor, especially with its heap size limits 6/12MB (...


5

You can use standard HTML input tags to achieve this, and the AJAX Toolkit to actually upload the attachments. Here is a basic example. First you need somewhere to select your files and something to start off the upload: <input id="file-input" type="file" name="file"/> <input type="button" value="Upload" onclick="uploadFile();"/> Then you ...


5

Have you tried using the html- prefix on your Visualforce component attributes? <apex:inputFile html-capture="camera" accept="txt" filename="{!fileName}" contentType="{!contentType}" value="{!photoUpload}" /></apex:form> https://www.salesforce.com/us/developer/docs/pages/Content/pages_html_features_pass_through_attributes.htm


5

You need a license to be able to upload data. There is no other way. You could consider temporarily (e.g. outside of office hours) deactivating a Sales Rep license and assigning the license to your data admin. Then after the upload is done, deactivate the data admin and re-activate the Sales Rep. Alternatively, purchase extra licenses...


5

Based on my research, I have concluded that at the time of this writing (using REST API v32), Salesforce does not decode uploaded base64 encoded data for Attachments. This is a bit confusing, since the Attachments documentation specifies the following: The API sends and receives the binary file attachment data encoded as a base64Binary data type. Prior ...


5

Attempt 1: As it was not possible via profiles, I tried doing it via permission set. I created a new permission set and added below permission for files Create Content Deliveries Create Public Links Moderate Communities Files And when I tried to assign that permission set to the guest site user, here is the error I get. It didn't let me assign ...


4

Obviously you can specify the height and width in an image tag in a VF page, but there is nothing built in to Salesforce that can do the image manipulation/processing that you are seeking. You might want to check out the AppExchange, but in my scan I didn't see anything there. Here is the idea to add Apex Image Processing. Vote it up. As @Killian said, ...


4

There is a product on the AppExchange that does this already.Drag and Drop Attachments


Only top voted, non community-wiki answers of a minimum length are eligible