VOOZH about

URL: https://froala.com/wysiwyg-editor/docs/sdks/ruby/references/file/

⇱ Ruby SDK File Reference - Froala


June Special:  New customers get 40% off all Froala licenses
Days
Hours
Minutes
Seconds
x
Skip to content
Froala Documentation

Ruby SDK File Reference

upload (params, fileRoute, options)

Returns: Object

Method used to upload file to the specified location on disk.

Parameters:


  • params

    The file that will be uploaded.

    Type: String

  • fileRoute

    The path relative to the Rails.root global variable were the file should be uploaded.

    Type: String

  • options

    This parameter is optional. It can be used to pass custom options for the file upload.

    Type: Array


options parameter:

  • fieldname

    The field name from the params[:file] global variable.

    Type: String
    Default:
    "file"
  • validation

    An array or a function used to validate the uploaded file.

    Type: Array or Function
    Default:
    validation: {
     allowedExts: [".txt", ".pdf", ".doc", ".json", ".html"],
     allowedMimeTypes: [ "text/plain", "application/msword", "application/x-pdf", "application/pdf", "application/json","text/html" ]
    }
    

Response

If the upload is completed successfully, the method returns an object with the absolute path to the uploaded file. If an error occurs, the method throws an exception.

class UploadController < ActionController::Base

 ...

 def upload_file
 options = {
 fieldname: 'file',
 validation: {
 allowedExts: [".txt", ".pdf", ".doc", ".json", ".html"],
 allowedMimeTypes: [ "text/plain", "application/msword", "application/x-pdf", "application/pdf", "application/json","text/html" ]
 }
 }
 render :json => FroalaEditorSDK::File.upload(params, "public/uploads/files/")
 end

 ...

end

delete ($src)

Returns: Boolean

Method used to delete a file from disk.

Parameters:


  • $src

    The path relative to the Rails.root global variable to the file that should be deleted.

    Type: String

Do you think we can improve this article? Let us know.

Ready to dive in? Explore our plans

Froala AI Assistant

Hello! I'm your Froala AI assistant. How can I help you today?

Press Enter to send your message
Need human help? We're just a message away—reach out here.
How was your chat experience?

Your feedback helps us improve our AI assistant.

0/500