0.01
No commit activity in last 3 years
No release in over 3 years
fastdfs upload file client for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 9.1.0
~> 3.4
 Project Readme

fastdfs-client-ruby

fastdfs client for ruby

Install

gem install 'fastdfs-client'

Using

  
  require 'fastdfs-client'

  # return the result format 
  #  {status: true, err_msg: "", result: ...}
  #


  tracker = Fastdfs::Client::Tracker.new(trackers: {host: "192.168.1.1", port: "22122"})

  # multiple trackers server
  # trackers: [
  #  {host: "192.168.1.1", port: "22122"},
  #  {host: "192.168.1.2", port: "22122"}
  # ]

  # socket connection KEEPALIVE
  tracker.pipeline do |s| 
    files.each do |file|
      s.upload(s)
    end
  end

  # @file class includes [File, Tempfile, ActionDispatch::Http::UploadedFile]
  @tracker.upload(@file)
  #result: {group_name: "group1", path: "m1/xfsd/fds.jpg"}

  @tracker.delete(path, group_name)  

  # flag params [cover, merge]
  @tracker.set_metadata(path, group_name, {author: "kaka", width: "300"}, flag)

  @tracker.get_metadata(path, group_name) 
  #result: {author: "kaka", width: "300"}

  @tracker.download(path, group_name) 
  #result: #<Tempfile:/var/folders/m7/bt2j0rk54x555t44dpn4b7bm0000gn/T/test.jpg20160416-43738-1560vq3>  

Make compatible 1.x version

  @storage = tracker.get_storage
  
  @storage.upload ...
  @storage.delete ...
  @storage.set_metadata ...
  @storage.get_metadata ...
  @storage.download ...

Contributing

Bug report or pull request are welcome.

License

MIT License