Giter Club home page Giter Club logo

Comments (5)

mech avatar mech commented on August 25, 2024

Hi thanks for finding it useful. I believe you can get the URL as a string type. This is how I do it for container type:

class Attachment
  include Filemaker::Model

  database 'MyDB'
  layout 'Attachment'

  # This is the container type URL being parse using URI.parse at
  # lib/filemaker/metadata/field.rb#L73
  string :attachment_url, fm_name: 'Attachment URL'
end

Do let me know if you can set it up :)

from filemaker-ruby.

alydersen avatar alydersen commented on August 25, 2024

Yes - my bad!

Do you have any functionality to get around the username/password dialog that is raised by the filmmaker server?

from filemaker-ruby.

mech avatar mech commented on August 25, 2024

You can download it using Net::HTTP with Basic Authentication:

def download_protected_file
  req = Net::HTTP::Get.new(attachment_url)
  req.basic_auth(ENV['FILEMAKER_ACCOUNT_NAME'], ENV['FILEMAKER_PASSWORD'])
  res = Net::HTTP.new(ENV['FILEMAKER_HOST'], 80)
  res = res.start { |http| http.request(req) }
  
  res.body
end

from filemaker-ruby.

alydersen avatar alydersen commented on August 25, 2024

Thanks! Did the following for https compatibility:

    uri = URI.parse("https://" + attachment_url)
    Net::HTTP.start(uri.host, uri.port,
      :use_ssl => uri.scheme == 'https',
      :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
      request = Net::HTTP::Get.new uri.request_uri
      request.basic_auth(ENV['FILEMAKER_ACCOUNT_NAME'], ENV['FILEMAKER_PASSWORD'])
      response = http.request request # Net::HTTPResponse object
      send_data(response.body, :filename => "filename.zip", :type => "application/zip, application/octet-stream")
    end

Have a create weekend!

Andreas

from filemaker-ruby.

mech avatar mech commented on August 25, 2024

Yup you 2 :)

from filemaker-ruby.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.