我正在尝试将所有文件下载到名为1.pdf,2.pdf的Firebase存储目录中。 该代码在调试模式下有效,但在发行版中无效。我整天都被困住了。 我认为这可能是从另一堂课上讲的,但是老实说,我不知道。
从Firebase获取文件的代码:
for (int i = 1; i < 10000; i++) {
StorageReference ref = storageRef.child("FirstTimeForms/" + i + ".pdf");
File localFile = File.createTempFile("Form", ".pdf");
FileDownloadTask dm = ref.getFile(localFile);
int fileSize = Integer.parseInt(String.valueOf(localFile.length()/1024));
if(fileSize > 0){
fileManager.copyFile(localFile, new File("/sdcard/Download/Forms/" + i + ".pdf"));
}else{
return;
}
}
将从缓存下载的文件复制到SD的代码
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try
{
inChannel.transferTo(0, inChannel.size(), outChannel);
}
finally
{
if (inChannel != null)
inChannel.close();
if (outChannel != null)
outChannel.close();
}
答案 0 :(得分:1)
将这些添加到您的proguard-rules.pro
# .ebextensions/01-http_basic_auth_staging.config
files:
/etc/nginx/.htpasswd:
mode: "000755"
owner: root
group: root
content: |
username:$apr1$k5WkOMBL$0FZNIWOLQMsHJAOREjemC/
/etc/nginx/conf.d/staging.conf:
mode: "000755"
owner: root
group: root
content: |
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://nodejs;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
/tmp/deployment/nginx_auth.sh:
mode: "000755"
content: |
sed -i 's/$proxy_add_x_forwarded_for;/$proxy_add_x_forwarded_for;\n auth_basic "Restricted";\n auth_basic_user_file \/etc\/nginx\/.htpasswd;\n/' /etc/nginx/conf.d/staging.conf
container_commands:
01nginx_auth:
command: "/tmp/deployment/nginx_auth.sh"
02restart_nginx:
command: "service nginx restart"