-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
html5 download #11
Comments
download image & renamehttps://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml5_a_download <!DOCTYPE html>
<html>
<body>
<p>Click on the w3schools logo to download the image:<p>
<a href="/images/myw3schoolsimage.jpg" download="xgqfrms">
<img src="/images/myw3schoolsimage.jpg" alt="W3Schools" width="104" height="142">
</a>
<p><b>Note:</b> The download attribute is not supported in Edge version 12, IE, Safari 10 (and earlier), or Opera version 12 (and earlier).</p>
</body>
</html> |
download pdf & rename
https://codepen.io/xgqfrms/full/GyEGzG/ https://stackoverflow.com/questions/3102226/how-to-set-name-of-file-downloaded-from-browser |
auto download imageshttps://www.w3schools.com/TAGS/att_a_download.asp <p>Click on the image to download it:<p>
<a href="/images/myw3schoolsimage.jpg" download>
img
</a> |
auto download icons |
auto download logos |
html5 download all in one |
HTML5 download 执行条件
demohttps://cdn.xgqfrms.xyz/HTML5/auto-dwonload-images/index.html
same originhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download https://caniuse.com/?search=download https://stackoverflow.com/questions/49760160/a-download-attribute-not-working-anymore |
https://cdn.xgqfrms.xyz/HTML5/Blob/fetch/index.html
https://cdn.xgqfrms.xyz/HTML5/auto-dwonload-images/index.html https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf ??? Node.js server return download file without extension filename |
Linux bash script 批量下载文件 All In One
https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l1.pdf
#!/bin/bash
# 下载目录
downdir="/Users/xgqfrms-mbp/Documents/swift-ui/Memorize/000-xyz/pdfs/"
# 读取文件
cat $1 | while read line
do
echo "$line"
cd $downdir
str=$line
# 按行分割,每行一个
array=(${str//;/ })
echo "$array"
url=${array[0]}
filename=$(echo ${array[1]} | tr -d '\r')
# filename=$(echo "l" + ${index} + ".pdf" | tr -d '\r')
# filename=$(echo "l${index}.pdf" | tr -d '\r')
# 执行下载
curl $url -o $filename
done
# chomd +x ./auto-download-pdfs.sh
# mkdir pdfs
# bash ./auto-download-pdfs.sh cs193p.txt
https://www.cnblogs.com/xgqfrms/p/16073509.html 作者:xgqfrms |
Node.js download remote cdn URL filehttps://www.npmjs.com/package/request
const fs = require("fs");
var path = require("path");
const { exit } = require("process");
const log = console.log;
const request = require("request");
// const request = require("request-promise-native");
var folder = path.resolve(__dirname, '../pdf');
// log('folder', folder);
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
async function downloadPDF(url, filename) {
log('🚧 pdf downloading ...');
const pdfBuffer = await request.get({
uri: url,
encoding: null,
// encoding: 'utf-8',
});
// write 下载文件 ✅ ??? Node.js 控制浏览器,下载文件还是打开预览文件 ???
fs.writeFileSync(filename, pdfBuffer);
log('✅ pdf finished!');
// exit 0;
}
const url = 'https://cs193p.sites.stanford.edu/sites/g/files/sbiybj16636/files/media/file/l1.pdf';
const filename = folder + '/cs193p-2021-l1.pdf';
// log('filename =', filename);
downloadPDF(url, filename);
|
attachmentvar express=require("express")
var app=express();
var fs = require('fs');
var path=require("path");
app.get("/upload",function(req,res){
var filePath = path.join(__dirname, './');
console.log(filePath)
fs.readFile(filePath+"images/2010191.png", function(err, data){
res.set({
'Content-Type': 'application/octet-stream',
//告诉浏览器这是一个二进制文件
'Content-Disposition': 'attachment; filename=upload.png' ,
//告诉浏览器这是一个附件要下载是png图片
});
res.end(data);
});
})
app.listen(3000, function(){
console.log("server is running", 3000);
}); |
Content-Disposition 内容处置 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Content-Disposition 在常规的 HTTP 应答中,Content-Disposition 响应头指示回复的内容该以何种形式展示,是以内联的形式(即网页或者页面的一部分),还是以附件的形式下载并保存到本地。 |
Node.js 服务器控制浏览器下载文件还是预览文件 All In One作者:xgqfrms |
HTTP response status code & 206 Partial Content All In One作者:xgqfrms |
HTML5 download 执行条件https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download
|
just need to use HTML5
|
html5 download & js
https://www.w3schools.com/TAGS/att_a_download.asp
https://stackoverflow.com/questions/2897619/using-html5-javascript-to-generate-and-save-a-file
https://developers.google.com/web/updates/2011/08/Downloading-resources-in-HTML5-a-download
The text was updated successfully, but these errors were encountered: