Search code examples
salesforcetwiliomms

Twilio MMS Send Local File


We can send MMS using Twilio api in Salesforce. As i know that using that code i can send MMS using Twilio in Salesforce.

Sending a MMS

properties.add(new TwilioNameValuePair('MediaUrl','https://www.twilio.com/packages/company/img/logos_downloadable_round.png'));

But it's seams that we have need to pass media file url. But how can we take a input of file form Local machine and send them using Twilio MMS?


Solution

  • Rajendra, hello! Megan from Twilio here.

    This sounds similar to what I ran into building an OpenCV MMS implementation in this blog post.

    The example there is in Python specifically, after writing an image to my local filesystem and making the desired modifications on it, I send it through:

    @app.route('/uploads/<filename>', methods=['GET', 'POST'])
    def uploaded_file(filename):
        return send_from_directory(UPLOAD_FOLDER,
                                   filename)
    

    which handles the delivery of the following TwiML:

     message.media('http://YourNgrokURL/uploads/{}'.format(filename))
    

    You'll be needing the equivalent of Flask's send_from_directory to handle this in your implementation.

    Hope this helps!