Project

General

Profile

Actions

Feature #7725

closed

REST API for files

Added by Alex Last about 13 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
2011-02-25
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate

Description

would be nice to have the API to manipulate files remotely.
e.g. to upload new distributives using some automated scripts.


Related issues

Related to Redmine - Feature #18245: Documents REST APINew

Actions
Related to Redmine - Feature #13800: File REST APINew

Actions
Related to Redmine - Patch #19116: Files REST APIClosedJean-Philippe Lang

Actions
Has duplicate Redmine - Feature #20404: REST API support for project files (attachments)Closed

Actions
Actions #1

Updated by j dlx almost 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

Actions #2

Updated by Gert van Dijk about 12 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.

Actions #3

Updated by Gert van Dijk about 12 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.

Actions #4

Updated by Bengt Lüers almost 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?

Actions #5

Updated by Dmitry Popov almost 11 years ago

Thanks, Gert! Your script works like a charm!

But still, API support would be appreciated.

Actions #6

Updated by Dmitry Popov almost 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

Actions #7

Updated by Lucile Quirion about 9 years ago

I also need a REST API for uploading files and noted that there is several open tickets concerning that feature (#18245, #13800)

So I've started working on it.
I'll try to include the patch submitted in #13800

Actions #8

Updated by Toshi MARUYAMA about 9 years ago

Actions #9

Updated by Toshi MARUYAMA about 9 years ago

Actions #10

Updated by Toshi MARUYAMA about 9 years ago

Actions #11

Updated by Mischa The Evil over 8 years ago

  • Has duplicate Feature #20404: REST API support for project files (attachments) added
Actions #12

Updated by Go MAEDA over 7 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

Implemented by #19116, will be available in upcoming 3.4.0.

Actions

Also available in: Atom PDF