Feature #7725
closedREST API for files
Added by Alex Last almost 16 years ago. Updated almost 10 years ago.
Description
would be nice to have the API to manipulate files remotely.
e.g. to upload new distributives using some automated scripts.
Updated by j dlx over 15 years ago
Actions
#1
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 over 14 years ago
Actions
#2
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 over 14 years ago
Actions
#3
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 13 years ago
Actions
#4
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 13 years ago
Actions
#5
Thanks, Gert! Your script works like a charm!
But still, API support would be appreciated.
Updated by Dmitry Popov over 13 years ago
Actions
#6
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
endHere'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 12 years ago
Actions
#7
Updated by Toshi MARUYAMA over 11 years ago
Actions
#8
- Related to Feature #18245: Documents REST API added
Updated by Toshi MARUYAMA over 11 years ago
Actions
#9
- Related to Feature #13800: File REST API added
Updated by Toshi MARUYAMA over 11 years ago
Actions
#10
- Related to Patch #19116: Files REST API added
Updated by Mischa The Evil over 11 years ago
Actions
#11
- Has duplicate Feature #20404: REST API support for project files (attachments) added
Updated by Go MAEDA almost 10 years ago
Actions
#12
- Status changed from New to Closed
- Resolution set to Duplicate
Implemented by #19116, will be available in upcoming 3.4.0.