Feature #7725
closedREST API for files
0%
Description
would be nice to have the API to manipulate files remotely.
e.g. to upload new distributives using some automated scripts.
Related issues
Updated by j dlx over 13 years ago
Alexey Skor wrote:
would be nice to have the API to manipulate files remotely.
e.g. to upload new distributives using some automated scripts.
Well for starters even a simple files list would do for me..
right now the only way (i know of) is to filter activity..
May i ask the maintainer/some official to get some word out on the files-API topic?
Reading through all/most threads regarding this topics, i still have no real clue if:
1. such a feature is planned (or at least considered) at all
2. if so, if there's a roadmap or something?
thx,
Jan
Updated by Gert van Dijk almost 13 years ago
Lately, some progress is made on the REST API features like the file attachments - see #8171. However, as far as I can see from the current documentation, it's still not possible to manage a project's 'Files' and 'Documents' using the REST API.
I would also like to see this feature for automated uploading of files; e.g. test builds after automated building in a post-receive/post-commit hook.
Updated by Gert van Dijk almost 13 years ago
In the meantime I created a Python script to overcome this. See redmine-file-uploader on GitHub.
I can now upload my builds from the build server to Redmine in the 'Files' section of the project for internal testing/deployment.
For anyone also in need of this; hope this helps.
Updated by Bengt Lüers over 11 years ago
The linked script works fine for uploading, but I would like to download files to mirror them in a Git repository. Is there any chance that this will make it into the API, soon or do I have to write something that does the downloading in the same fashion?
Updated by Dmitry Popov over 11 years ago
Thanks, Gert! Your script works like a charm!
But still, API support would be appreciated.
Updated by Dmitry Popov over 11 years ago
I've rewritten the script in Ruby:
require 'mechanize'
# Replaces \ with / and removes "
ARGV.map!{|a|a.gsub('\\','/').gsub(/^"(.+)"$/,'\\1')}
filename = ARGV[0] || abort('Filename must be specified')
puts "File: #{filename}"
url = ARGV[1] || abort('Redmine URL must be specified')
puts "Redmine URL: #{url}"
username = ARGV[2] || abort('Redmine username must be specified')
puts "Username: #{username}"
password = ARGV[3] || abort('Redmine password must be specified')
puts "Password: #{'*' * password.length}"
project = ARGV[4] || abort('Redmine project must be specified')
puts "Project: #{project}"
login_page_path = '/login'
files_page_path = '/projects/' + project + '/files'
agent = Mechanize.new
# No certificate verification (I had to use this hack because our server is bound to custom port)
# agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
agent.get(URI.join(url, login_page_path)) do |login_page|
login_page.form_with(:action => login_page_path) do |login_form|
login_form.username = username
login_form.password = password
end.submit
end
agent.get(URI.join(url, files_page_path + '/new')) do |upload_page|
upload_page.form_with(:action => files_page_path) do |upload_form|
upload_form.file_uploads.first.file_name = filename
end.submit
end
Here's the script to delete uploaded files:
agent.get(URI.join(url, files_page_path)) do |files_page|
file_link = files_page.link_with(:text => File.basename(filename))
if file_link
file_id = file_link.href.match(/download\/(\d+)/)[1].to_i
agent.post(URI.join(url, "/attachments/#{file_id}"), {'_method' => 'delete', 'authenticity_token' => files_page.at('meta[@name="csrf-token"]')[:content]})
end
end
Updated by Lucile Quirion almost 10 years ago
Updated by Toshi MARUYAMA almost 10 years ago
- Related to Feature #18245: Documents REST API added
Updated by Toshi MARUYAMA almost 10 years ago
- Related to Feature #13800: File REST API added
Updated by Toshi MARUYAMA almost 10 years ago
- Related to Patch #19116: Files REST API added
Updated by Mischa The Evil over 9 years ago
- Has duplicate Feature #20404: REST API support for project files (attachments) added
Updated by Go MAEDA almost 8 years ago
- Status changed from New to Closed
- Resolution set to Duplicate
Implemented by #19116, will be available in upcoming 3.4.0.