function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Harish BasthapurHarish Basthapur 

On Uploading a File from force.com to amazon S3, How to Round the size of the Files for the files

Hi all,

 

I am able to build an application which uploads the files from force.com to amazon aws S3,

but also,I need to round the size of the Files uploaded into S3, I had tried with some code like using ifelse

 

 

public Blob fileBlob {get;set;}     /*Important one*/
public Integer fileSize {get;set;}
public String fileName {get;set;}

.

.

.

.

public pageReference syncFilesystemDoc(){
try

{
system.debug('Entered try suncFileSystemDoc method');
system.debug('FileSize is '+FileSize);
system.debug('accessTypeSelected is'+accessTypeSelected);
Datetime now = Datetime.now();
if(FileSize < 1000.00){
FileSize=1000;}
else if(FileSize <4000.00){
FileSize=4000;}
else if(FileSize <8000.00){
FileSize=8000;}
else{
FileSize= 12000;}
String docBody = EncodingUtil.base64Encode(fileBlob);
System.debug('File blob size is ' + fileBlob);
//TODO - make sure doc.bodyLength is not greater than 100000 to avoid apex limits
System.debug('File size after the ifelse loop is: ' + fileSize);
uploadObjectErrorMsg = 'Error';
Boolean putObjResult = as3.PutObjectInline_ACL(bucketToUploadObject,FolderToUploadObject,fileName,null,docBody,fileSize,accessTypeSelected,as3.key,now,as3.signature('PutObjectInline',now),as3.secret, OwnerId);
if(putObjResult==true){
System.debug('putobjectinline successful');
uploadObjectErrorMsg = 'Success';
}
}catch(System.CalloutException callout){
System.debug('CALLOUT EXCEPTION: ' + callout);
uploadObjectErrorMsg = callout.getMessage();
}catch(Exception ex){
System.debug('EXCEPTION: ' + ex);
uploadObjectErrorMsg = ex.getMessage();
}
return null;
}

 

 

Iam  able to round the size of the file, which can be observed only through the Force.com Debug log’s only within the Force.com, but in S3 there is some problem , which is not reflected over there, I mean the code is not working.It is perfect for File Upload but "How to Round the size of File/Folder"

 

Thanx in advance!