1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 23:51:06 +01:00

Replace deprecated methods in actix_files (#1027)

* Bump up mime_guess to 2.0.1

* Replace deprecated methods

* Update CHANGE.md
This commit is contained in:
Yuki Okushi 2019-08-12 05:43:29 +09:00 committed by GitHub
parent 0ee69671ba
commit dbe4c9ffb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,9 @@
# Changes
## [0.1.5] - unreleased
* Bump up `mime_guess` crate version to 2.0.1
## [0.1.4] - 2019-07-20
* Allow to disable `Content-Disposition` header #686

View File

@ -27,7 +27,7 @@ futures = "0.1.25"
derive_more = "0.15.0"
log = "0.4"
mime = "0.3"
mime_guess = "2.0.0-alpha"
mime_guess = "2.0.1"
percent-encoding = "1.0"
v_htmlescape = "0.4"

View File

@ -22,7 +22,7 @@ use bytes::Bytes;
use futures::future::{ok, Either, FutureResult};
use futures::{Async, Future, Poll, Stream};
use mime;
use mime_guess::get_mime_type;
use mime_guess::from_ext;
use percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET};
use v_htmlescape::escape as escape_html_entity;
@ -42,7 +42,7 @@ type HttpNewService = BoxedNewService<(), ServiceRequest, ServiceResponse, Error
/// the type `application/octet-stream`.
#[inline]
pub fn file_extension_to_mime(ext: &str) -> mime::Mime {
get_mime_type(ext)
from_ext(ext).first_or_octet_stream()
}
#[doc(hidden)]

View File

@ -9,7 +9,7 @@ use std::os::unix::fs::MetadataExt;
use bitflags::bitflags;
use mime;
use mime_guess::guess_mime_type;
use mime_guess::from_path;
use actix_http::body::SizedStream;
use actix_web::http::header::{
@ -88,7 +88,7 @@ impl NamedFile {
}
};
let ct = guess_mime_type(&path);
let ct = from_path(&path).first_or_octet_stream();
let disposition_type = match ct.type_() {
mime::IMAGE | mime::TEXT | mime::VIDEO => DispositionType::Inline,
_ => DispositionType::Attachment,