# How can I import/export settings into a file?

**URL:** <https://meta.discourse.org/t/how-can-i-import-export-settings-into-a-file/51496>\
**Category:** Product Support\
**Created:** [2016 年10 月 13 日 11:41 UTC](https://meta.discourse.org/t/how-can-i-import-export-settings-into-a-file/51496 "2016-10-13T11:41:59Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

作者： ![pgr](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pgr/32/156783_2.png) [@pgr](https://meta.discourse.org/u/pgr)\
发布日期： [2019 年9 月 22 日 12:11 UTC](https://meta.discourse.org/t/how-can-i-import-export-settings-into-a-file/51496/8 "2019-09-22T12:11:12Z")

</div>

供将来参考，我在使用 `discourse-settings-uploader` 时遇到的一些问题，导致出现 301 错误：

```plaintext
./discourse-settings-uploader community.mysite.com 22f7d44321ae2365d3e3a5e9224524ba0e7302bd75ed06bfbh31ed5090ec6d3b system site-settings.json
SiteSettingtitle="Mysite"
E! 301 Moved Permanently

```

每个设置都会出现一次此错误。但我可以成功通过浏览器访问这些 URL。因此我意识到——它正在使用 `http`，而该协议已被禁用。

于是，我在站点名称中添加了 `https`，结果得到了一个不同的错误：

```plaintext
SiteSettingtitle="My sIte"
E! SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)
something's wrong with https://community.mysite.com/admin/site_settings/title {"title"=>"Mysite", :api_key=>"22f7d44321ae2365d3e3a5e9224524ba0e7302bd75ed06bfbh31ed5090ec6d3b ec6d3b", :api_username=>"system"}

```

看来这归根结底是本地根证书配置不足的问题。我本可以花一下午时间去解决它，但我选择直接关闭 `verify_ssl`。 **这非常不安全，可能会给你带来可怕的后果，甚至殃及你的子孙后代** ，但在这种情况下，我根本不在乎。

因此，我在上传脚本中添加了以下方法：

```ruby
def put_no_ssl(url, payload, headers={}, &block)
  RestClient::Request.execute(method: :put, url: url, :payload => payload, headers: headers, verify_ssl: false, &block)
end

```

然后，我将调用从

```ruby
r = RestClient.put(url, my_hash)

```

改为

```ruby
r = put_no_ssl(url, my_hash)

```

结果成功了！🕶

---

_[View the full topic](https://meta.discourse.org/t/how-can-i-import-export-settings-into-a-file/51496)._
