diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
commit | 074785cea106179cb3305637055ab0a009ca74f2 (patch) | |
tree | e6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/pt-pt/web/api/file | |
parent | da78a9e329e272dedb2400b79a3bdeebff387d47 (diff) | |
download | translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2 translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip |
initial commit
Diffstat (limited to 'files/pt-pt/web/api/file')
-rw-r--r-- | files/pt-pt/web/api/file/file/index.html | 71 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/filename/index.html | 37 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/filesize/index.html | 37 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/getasbinary/index.html | 77 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/getasdataurl/index.html | 67 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/getastext/index.html | 83 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/index.html | 101 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/lastmodified/index.html | 113 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/lastmodifieddate/index.html | 80 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/mozfullpath/index.html | 17 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/name/index.html | 74 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/type/index.html | 75 | ||||
-rw-r--r-- | files/pt-pt/web/api/file/webkitrelativepath/index.html | 80 |
13 files changed, 912 insertions, 0 deletions
diff --git a/files/pt-pt/web/api/file/file/index.html b/files/pt-pt/web/api/file/file/index.html new file mode 100644 index 0000000000..a785c59a41 --- /dev/null +++ b/files/pt-pt/web/api/file/file/index.html @@ -0,0 +1,71 @@ +--- +title: File.File() +slug: Web/API/File/File +tags: + - API + - Construtor + - File API + - Referencia +translation_of: Web/API/File/File +--- +<div>{{APIRef("File")}}</div> + +<p>O construtor <code><strong>File()</strong></code> cria uma instância do objeto {{domxref("File")}}.</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox notranslate">new File(bits, name[, options]);</pre> + +<h3 id="Parâmetros">Parâmetros</h3> + +<dl> + <dt><code>bits</code></dt> + <dd>Uma {{jsxref("Array")}} de objetos {{jsxref("ArrayBuffer")}}, {{domxref("ArrayBufferView")}}, {{domxref("Blob")}}, {{domxref("USVString")}}, ou um misto de tais objetos, que será posto no {{domxref("File")}}. Objetos <code>USVString</code> são codificados em UTF-8.</dd> + <dt><code>name</code></dt> + <dd>Uma {{domxref("USVString")}} que representa o nome do ficheiro ou o caminho para o ficheiro.</dd> + <dt><code>options</code> {{optional_inline}}</dt> + <dd>Um objeto com atributos opcionais para o ficheiro. As opções disponíveis são: + <ul> + <li><code>type</code>: Uma {{domxref("DOMString")}} que representa o tipo MIME do conteúdo será posto no ficheiro. Tem um valor pré-definido de <code>""</code>.</li> + <li><code>lastModified</code>: Um número que representa o número de milissegundos entre o início da era Unix e a última data em que o ficheiro foi modificado. Tem um valor pré-definido de {{jsxref("Date.now()")}}.</li> + </ul> + </dd> +</dl> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush: js notranslate">var file = new File(["foo"], "foo.txt", { + type: "text/plain", +});</pre> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Estado</th> + <th scope="col">Comentários</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('File API')}}</td> + <td>{{Spec2('File API')}}</td> + <td>Definição inicial</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade">Compatibilidade</h2> + + + +<p>{{Compat("api.File.File")}}</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("FileReader")}}</li> + <li>{{domxref("Blob")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/filename/index.html b/files/pt-pt/web/api/file/filename/index.html new file mode 100644 index 0000000000..0e0ee197ae --- /dev/null +++ b/files/pt-pt/web/api/file/filename/index.html @@ -0,0 +1,37 @@ +--- +title: File.fileName +slug: Web/API/File/fileName +tags: + - API + - DOM + - Ficheiros + - File API + - Non-standard + - Obsoleto + - Propriedade + - Referencia +translation_of: Web/API/File/fileName +--- +<div>{{APIRef("File API")}}{{non-standard_header}} {{obsolete_header(7.0)}}</div> + +<p>Retorna o nome do ficheiro. Por razões de segurança o caminho é excluído desta propriedade.</p> + +<div class="note">Esta propriedade está obsoleta. Use antes {{domxref("File.name")}}.</div> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox notranslate">var <em>name</em> = <em>instanceOfFile</em>.fileName;</pre> + +<h3 id="Valor">Valor</h3> + +<p>Uma <em>string</em></p> + +<h2 id="Specification" name="Specification">Especificação</h2> + +<p>Não faz parte duma especificação.</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("File.name")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/filesize/index.html b/files/pt-pt/web/api/file/filesize/index.html new file mode 100644 index 0000000000..e17676ecee --- /dev/null +++ b/files/pt-pt/web/api/file/filesize/index.html @@ -0,0 +1,37 @@ +--- +title: File.fileSize +slug: Web/API/File/fileSize +tags: + - API + - DOM + - Ficheiros + - File API + - Non-standard + - Obsoleto + - Propriedade + - Referencia +translation_of: Web/API/File/fileSize +--- +<p>{{APIRef("File API") }}{{non-standard_header}} {{deprecated_header(7.0)}}</p> + +<p>Retorna o tamanho do ficheiro em <em>bytes</em>.</p> + +<div class="note">Esta propriedade está obsoleta. Use antes {{domxref("Blob.size")}}.</div> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox notranslate">var <em>size</em> = <em>instanceOfFile</em>.fileSize;</pre> + +<h3 id="Valor">Valor</h3> + +<p>Um número.</p> + +<h2 id="Especificação">Especificação</h2> + +<p>Não faz parte de nenhuma especificação.</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("Blob.size")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/getasbinary/index.html b/files/pt-pt/web/api/file/getasbinary/index.html new file mode 100644 index 0000000000..8ec42cf1f2 --- /dev/null +++ b/files/pt-pt/web/api/file/getasbinary/index.html @@ -0,0 +1,77 @@ +--- +title: File.getAsBinary() +slug: Web/API/File/getAsBinary +tags: + - API + - Ficheiros + - File API + - Non-standard + - Obsoleto + - Referencia + - metodo +translation_of: Web/API/File/getAsBinary +--- +<p>{{APIRef("File API")}}</p> + +<p>{{non-standard_header}}</p> + +<p>{{obsolete_header(7.0)}}</p> + +<h2 id="Sumário">Sumário</h2> + +<p>O método <code>getAsBinary</code> permite aceder aos dados de um ficheiro num formato <em>raw</em> binário.</p> + +<div class="note"> +<p><strong>Nota:</strong> Este método é obsoleto; use antes o método {{domxref("FileReader.readAsBinaryString()","readAsBinaryString()")}} ou {{domxref("FileReader.readAsArrayBuffer()","readAsArrayBuffer()")}} de {{domxref("FileReader")}}.</p> +</div> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="notranslate">var binary = <em>instanceOfFile</em>.getAsBinary();</pre> + +<h3 id="Retorna">Retorna</h3> + +<p>Uma <em>string</em>.</p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush:js; notranslate">// fileInput é um HTMLInputElement: <input type="file" id="myfileinput" multiple> +var fileInput = document.getElementById("myfileinput"); + +// files é um objeto de FileList (parecido ao NodeList) +var files = fileInput.files; + +// objeto com os tipos de media permitidos +var accept = { + binary : ["image/png", "image/jpeg"], + text : ["text/plain", "text/css", "application/xml", "text/html"] +}; + +var file; + +for (var i = 0; i < files.length; i++) { + file = files[i]; + + // se o ficheiro pode ser detetado + if (file !== null) { + if (accept.binary.indexOf(file.type) > -1) { + // file contem dados binarios, num formato permitido + var data = file.getAsBinary(); + } else if (accept.text.indexOf(file.type) > -1) { + // file contem texto, num formato permitido + var data = file.getAsText(); + // modificar dados com métodos de string + } + } +}</pre> + +<h2 id="Specification" name="Specification">Especificação</h2> + +<p>Não pertence a nenhuma especificação.</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("File")}}</li> + <li>{{domxref("FileReader")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/getasdataurl/index.html b/files/pt-pt/web/api/file/getasdataurl/index.html new file mode 100644 index 0000000000..e3e5bae4b3 --- /dev/null +++ b/files/pt-pt/web/api/file/getasdataurl/index.html @@ -0,0 +1,67 @@ +--- +title: File.getAsDataURL() +slug: Web/API/File/getAsDataURL +tags: + - API + - Ficheiros + - File API + - Non-standard + - Obsoleto + - Referencia + - metodo +translation_of: Web/API/File/getAsDataURL +--- +<div>{{APIRef("File API") }}</div> + +<p>{{non-standard_header}}</p> + +<p>{{deprecated_header(7.0)}}</p> + +<h2 id="Sumário">Sumário</h2> + +<p><span class="seoSummary">O método <code>getAsDataURL</code> retorna um URL em estilo <a href="/en-US/docs/data_URIs"><code>data:</code></a> que codifica todo o conteúdo do ficheiro em questão.</span></p> + +<div class="note"> +<p><strong>Nota:</strong> Este método está obsoleto: use antes o método {{domxref("FileReader.readAsDataURL","readAsDataURL()")}} de {{domxref("FileReader")}}.</p> +</div> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="notranslate">var url = <var>instanceOfFile</var>.getAsDataURL();</pre> + +<h3 id="Retorna">Retorna</h3> + +<p>Uma string a representar um URL de estilo <a href="/en-US/docs/data_URIs"><code>data:</code></a></p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush: js notranslate">// fileInput é um HTMLInputElement: <input type="file" id="myfileinput" multiple> +var fileInput = document.getElementById("myfileinput"); + +// files é um objeto FileList (parecido ao NodeList) +var files = fileInput.files; + +// accept é um array com tipos de ficheiros aceites +var accept = ["image/png"]; + +// img é um HTMLImgElement: <img id="myimg"> +var img = document.getElementById("myimg"); + +// se aceitamos o primeiro tipo de ficheiro selecionado +if (accept.indexOf(files[0].mediaType) > -1) { + // apresentar a imagem + // igual a <img src="data:image/png,<imagedata>"> + img.src = files[0].getAsDataURL(); +} +</pre> + +<h2 id="Especificação">Especificação</h2> + +<p>Não pertence a nenhuma especificação.</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("File")}}</li> + <li>{{domxref("FileReader")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/getastext/index.html b/files/pt-pt/web/api/file/getastext/index.html new file mode 100644 index 0000000000..b20229737e --- /dev/null +++ b/files/pt-pt/web/api/file/getastext/index.html @@ -0,0 +1,83 @@ +--- +title: File.getAsText() +slug: Web/API/File/getAsText +tags: + - API + - Ficheiros + - File API + - Non-standard + - Obsoleto + - Referencia + - metodo +translation_of: Web/API/File/getAsText +--- +<p>{{APIRef("File API") }}{{non-standard_header}}</p> + +<p>{{obsolete_header(7.0)}}</p> + +<h2 id="Sumário">Sumário</h2> + +<p>O método <code>getAsText</code> oferece os dados do ficheiro num formato de texto de acordo com uma codificação.</p> + +<div class="note"> +<p><strong>Note:</strong> Este método está obsoleto; use antes o método {{domxref("FileReader.readAsText()","readAsText()")}} de {{domxref("FileReader")}}.</p> +</div> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="notranslate">var <var>str</var> = <var>instanceOfFile</var>.getAsText(<var>encoding</var>);</pre> + +<h3 id="Parâmetros">Parâmetros</h3> + +<dl> + <dt><var>encoding</var></dt> + <dd>Uma <em>string</em> a indicar qual a codificação para usar nos dados devolvidos. Se o <em>string</em> estiver vazio, é utilizado UTF-8.</dd> +</dl> + +<h3 id="Retorna">Retorna</h3> + +<p>A string que contem os dados do ficheiro num formato de texto especificado pelo <code>encoding</code>.</p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush: js notranslate">// fileInput é um HTMLInputElement: <input type="file" id="myfileinput" multiple> +var fileInput = document.getElementById("myfileinput"); + +// files é um objeto de FileList (parecido ao NodeList) +var files = fileInput.files; + +// object com os formatos de media validos +var accept = { + binary : ["image/png", "image/jpeg"], + text : ["text/plain", "text/css", "application/xml", "text/html"] +}; + +var file; + +for (var i = 0; i < files.length; i++) { + file = files[i]; + + // se o formato do ficheiro foi detetado + if (file !== null) { + if (accept.text.indexOf(file.mediaType) > -1) { + // file contem texto, num formato permitido + // make sure it's encoded as utf-8 + var data = file.getAsText("utf-8"); + // modificar dados com métodos de string + + } else if (accept.binary.indexOf(file.mediaType) > -1) { + // binario + } + } +}</pre> + +<h2 id="Especificação">Especificação</h2> + +<p>Não pertence a nenhuma especificação.</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("File")}}</li> + <li>{{domxref("FileReader")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/index.html b/files/pt-pt/web/api/file/index.html new file mode 100644 index 0000000000..43e85438cb --- /dev/null +++ b/files/pt-pt/web/api/file/index.html @@ -0,0 +1,101 @@ +--- +title: File +slug: Web/API/File +tags: + - API + - File API + - Interface + - NeedsTranslation + - Reference + - TopicStub + - Web +translation_of: Web/API/File +--- +<div>{{APIRef}}</div> + +<p>The <strong><code>File</code></strong> interface provides information about files and allows JavaScript in a web page to access their content.</p> + +<p><code>File</code> objects are generally retrieved from a {{DOMxRef("FileList")}} object returned as a result of a user selecting files using the {{HTMLElement("input")}} element, from a drag and drop operation's {{DOMxRef("DataTransfer")}} object, or from the <code>mozGetAsFile()</code> API on an {{DOMxRef("HTMLCanvasElement")}}.</p> + +<p>A <code>File</code> object is a specific kind of a {{DOMxRef("Blob")}}, and can be used in any context that a Blob can. In particular, {{DOMxRef("FileReader")}}, {{DOMxRef("URL.createObjectURL()")}}, {{DOMxRef("ImageBitmapFactories.createImageBitmap()", "createImageBitmap()")}}, and {{DOMxRef("XMLHttpRequest", "", "send()")}} accept both <code>Blob</code>s and <code>File</code>s.</p> + +<p>See <a href="/en-US/docs/Using_files_from_web_applications">Using files from web applications</a> for more information and examples.</p> + +<p>{{InheritanceDiagram}}</p> + +<h2 id="Constructor">Constructor</h2> + +<dl> + <dt>{{DOMxRef("File.File", "File()")}}</dt> + <dd>Returns a newly constructed <code>File</code>.</dd> +</dl> + +<h2 id="Instance_properties">Instance properties</h2> + +<dl> + <dt>{{DOMxRef("File.prototype.lastModified")}} {{ReadOnlyInline}}</dt> + <dd>Returns the last modified time of the file, in millisecond since the UNIX epoch (January 1st, 1970 at Midnight).</dd> + <dt>{{DOMxRef("File.prototype.lastModifiedDate")}} {{Deprecated_Inline}} {{ReadOnlyInline}}</dt> + <dd>Returns the last modified {{JSxRef("Date")}} of the file referenced by the <code>File</code> object.</dd> + <dt>{{DOMxRef("File.prototype.name")}}{{ReadOnlyInline}}</dt> + <dd>Returns the name of the file referenced by the <code>File</code> object.</dd> + <dt>{{DOMxRef("File.prototype.webkitRelativePath")}} {{Non-standard_Inline}} {{ReadOnlyInline}}</dt> + <dd>Returns the path the URL of the {{DOMxRef("File")}} is relative to.</dd> +</dl> + +<p><code>File</code> implements {{DOMxRef("Blob")}}, so it also has the following properties available to it:</p> + +<dl> + <dt>{{DOMxRef("File.prototype.size")}} {{ReadOnlyInline}}</dt> + <dd>Returns the size of the file in bytes.</dd> + <dt>{{DOMxRef("File.prototype.type")}} {{ReadOnlyInline}}</dt> + <dd>Returns the <a href="/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME </a>type of the file.</dd> +</dl> + +<h2 id="Instance_methods">Instance methods</h2> + +<p><em>The <code>File</code> interface doesn't define any methods, but inherits methods from the {{DOMxRef("Blob")}} interface:</em></p> + +<dl> + <dt>{{DOMxRef("Blob.prototype.slice()", "Blob.prototype.slice([start[, end[, contentType]]])")}}</dt> + <dd>Returns a new <code>Blob</code> object containing the data in the specified range of bytes of the source <code>Blob</code>.</dd> + <dt>{{DOMxRef("Blob.prototype.stream()")}}</dt> + <dd>Transforms the <code>File</code> into a {{DOMxRef("ReadableStream")}} that can be used to read the <code>File</code> contents.</dd> + <dt>{{DOMxRef("Blob.prototype.text()")}}</dt> + <dd>Transforms the <code>File</code> into a stream and reads it to completion. It returns a promise that resolves with a {{DOMxRef("USVString")}} (text).</dd> + <dt>{{DOMxRef("Blob.prototype.arrayBuffer()")}}</dt> + <dd>Transforms the <code>File</code> into a stream and reads it to completion. It returns a promise that resolves with an {{DOMxRef("ArrayBuffer")}}.</dd> +</dl> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('File API', "#file-section", "The <code>File</code> interface")}}</td> + <td>{{Spec2('File API')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.File")}}</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/File/Using_files_from_web_applications">Using files from web applications</a></li> + <li>{{DOMxRef("FileReader")}}</li> + <li><a href="/en-US/docs/Extensions/Using_the_DOM_File_API_in_chrome_code">Using the DOM File API in chrome code</a> (for privileged code running in Gecko, such as Firefox add-ons)</li> +</ul> diff --git a/files/pt-pt/web/api/file/lastmodified/index.html b/files/pt-pt/web/api/file/lastmodified/index.html new file mode 100644 index 0000000000..9b05f6f3cf --- /dev/null +++ b/files/pt-pt/web/api/file/lastmodified/index.html @@ -0,0 +1,113 @@ +--- +title: File.lastModified +slug: Web/API/File/lastModified +tags: + - API + - Ficheiros + - File API + - Propriedade + - Referencia +translation_of: Web/API/File/lastModified +--- +<div>{{APIRef("File")}}</div> + +<p>A propriedade <em>read-only</em> <code><strong>File.lastModified</strong></code> indica a ultima data em que o ficheiro foi modificado, na forma do numero de milissegundos desde o início da era Unix (1 de janeiro de 1970 às 00:00:00). Os ficheiros cuja a data da última modificação não é conhecida devolvem a data actual.</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox notranslate">const <em>tempo</em> = <em>instanciaDeFicheiro</em>.lastModified; +</pre> + +<h3 id="Valor">Valor</h3> + +<p>Um número que representa o número de milissegundos desde o início da época do Unix.</p> + +<h2 id="Exemplo">Exemplo</h2> + +<h3 id="Leitura_a_partir_da_entrada_do_ficheiro">Leitura a partir da entrada do ficheiro</h3> + +<pre class="brush: html notranslate"><input type="file" multiple id="entradaDeFicheiro"> +</pre> + +<pre class="brush:js notranslate">const entradaDeFicheiro = document.querySelector('#entradaDeFicheiro'); +entradaDeFicheiro.addEventListener('change', (event) => { + // ficheiros é um objeto de FileList (semelhante a NodeList) + const ficheiros = event.target.files; + + for (let ficheiro of ficheiros) { + const data = new Date(ficheiro.lastModified); + console.log(`${ficheiro.name} tem uma última data modificada de ${data}`); + } +}); +</pre> + +<p>Veja os resultados abaixo:</p> + +<p>{{ EmbedLiveSample('Leitura_a_partir_da_entrada_do_ficheiro', 300, 50) }}</p> + +<h3 id="Ficheiros_criados_dinamicamente">Ficheiros criados dinamicamente</h3> + +<p>Se um objeto File for criado dinamicamente, a última data modificada pode ser fornecida na função construtor {{domxref("File.File()", "new File()")}}. Se estiver em falta, lastModified herda a hora actual de {{jsxref("Date.now()")}} no momento em que o objeto File é criado.</p> + +<pre class="brush:js notranslate">const ficheiroComData = new File([], 'file.bin', { + lastModified: new Date(2017, 1, 1), +}); +console.log(ficheiroComData.lastModified); //devolve 1485903600000 + +const ficheiroSemData = new File([], 'file.bin'); +console.log(ficheiroSemData.lastModified); //devolve data atual em milissegundos +</pre> + +<h2 id="Reduced_time_precision">Reduced time precision</h2> + +<p>To offer protection against timing attacks and fingerprinting, the precision of <code>someFile.lastModified</code> might get rounded depending on browser settings.<br> + In Firefox, the <code>privacy.reduceTimerPrecision</code> preference is enabled by default and defaults to 20us in Firefox 59; in 60 it will be 2ms.</p> + +<pre class="brush: js notranslate">// reduced time precision (2ms) in Firefox 60 +someFile.lastModified; +// 1519211809934 +// 1519211810362 +// 1519211811670 +// ... + + +// reduced time precision with `privacy.resistFingerprinting` enabled +someFile.lastModified; +// 1519129853500 +// 1519129858900 +// 1519129864400 +// ... +</pre> + +<p>In Firefox, you can also enabled <code>privacy.resistFingerprinting</code>, the precision will be 100ms or the value of <code>privacy.resistFingerprinting.reduceTimerPrecision.microseconds</code>, whichever is larger.</p> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Estado</th> + <th scope="col">Comentários</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('File API', '#file-attrs', 'lastModified')}}</td> + <td>{{Spec2('File API')}}</td> + <td>Definição inicial.</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade">Compatibilidade</h2> + + + +<p>{{Compat("api.File.lastModified")}}</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("File")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/lastmodifieddate/index.html b/files/pt-pt/web/api/file/lastmodifieddate/index.html new file mode 100644 index 0000000000..10d5d8c932 --- /dev/null +++ b/files/pt-pt/web/api/file/lastmodifieddate/index.html @@ -0,0 +1,80 @@ +--- +title: File.lastModifiedDate +slug: Web/API/File/lastModifiedDate +tags: + - API + - Ficheiros + - File + - File API + - Obsoleto + - Propriedade + - Read-only + - Referencia + - lastDateModified +translation_of: Web/API/File/lastModifiedDate +--- +<div>{{APIRef("File API") }} {{deprecated_header}}</div> + +<p>A propriedade <em>read-only</em> <code><strong>File.lastModifiedDate</strong></code><strong> </strong>devolve a ultima data em que o ficheiro foi modificado. Ficheiros onde a ultima data de modificação é desconhecida devolvem a data atual.</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="notranslate">var time = <em>instanceOfFile</em>.lastModifiedDate</pre> + +<h3 id="Valor">Valor</h3> + +<p>Um objeto <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date">Date</a></code> a indicar a data e hora da ultima modificação ao ficheiro.</p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush:js notranslate">// fileInput é um HTMLInputElement: <input type="file" multiple id="myfileinput"> +var fileInput = document.getElementById("myfileinput"); + +// files é um objeto de FileList (parecido ao NodeList) +var files = fileInput.files; + +for (var i = 0; i < files.length; i++) { + alert(files[i].name + " has a last modified date of " + files[i].lastModifiedDate); +}</pre> + +<h2 id="Precisão_reduzida">Precisão reduzida</h2> + +<p>Para oferecer proteção contra <em>timing attacks</em> e <em>fingerprinting</em> a precisão de <code>someFile.lastModifiedDate.getTime()</code> pode ser arredondada dependente das preferências no navegador.</p> + +<p>No Firefox, a preferência <code>privacy.reduceTimerPrecision</code> está ligada por pré-definição com valores arredondados aos 20μs mais próximos no Firefox 59; e no Firefox 60 aos 2ms.</p> + +<pre class="brush: js notranslate">// precisão reduzida (2ms) no Firefox 60 +someFile.lastModifiedDate.getTime(); +// 1519211809934 +// 1519211810362 +// 1519211811670 +// ... + + +// precisão reduzida com a `privacy.resistFingerprinting` ligada +someFile.lastModifiedDate.getTime(); +// 1519129853500 +// 1519129858900 +// 1519129864400 +// ... +</pre> + +<p>No Firefox, também pode ligar a preferência <code>privacy.resistFingerprinting</code>, a precisão será arredondada aos 100ms mais próximos ou ao valor de <code>privacy.resistFingerprinting.reduceTimerPrecision.microseconds</code>, o que for maior.</p> + +<h2 id="Especificações">Especificações</h2> + +<p>Apesar de estar presente numa versão inicial do esboço do File API <em>spec</em>, esta propriedade foi removida e agora é <em>non-standard</em>. Use antes {{domxref("File.lastModified")}}.</p> + +<h2 id="Compatibilidade">Compatibilidade</h2> + +<div> + + +<p>{{Compat("api.File.lastModifiedDate")}}</p> +</div> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li>{{domxref("File")}}</li> +</ul> diff --git a/files/pt-pt/web/api/file/mozfullpath/index.html b/files/pt-pt/web/api/file/mozfullpath/index.html new file mode 100644 index 0000000000..24e126847f --- /dev/null +++ b/files/pt-pt/web/api/file/mozfullpath/index.html @@ -0,0 +1,17 @@ +--- +title: File.mozFullPath +slug: Web/API/File/mozFullPath +tags: + - API + - Ficheiros + - File + - File API + - Non-standard + - Propriedade + - Referencia + - mozFullPath +translation_of: Web/API/File/mozFullPath +--- +<div>{{APIRef("File API")}}{{draft}}{{Non-standard_header}}</div> + +<p><span class="seoSummary">Uma extensão privilegiada para a interface {{domxref("File")}}, a propriedade <code>mozFullPath</code> contém o caminho completo do ficheiro representado.</span> Esta propriedade só está disponível a partir do código do navegador ou de extensões Firefox ao estilo antigo com base no XPCOM. Não está disponível para o conteúdo da web.</p> diff --git a/files/pt-pt/web/api/file/name/index.html b/files/pt-pt/web/api/file/name/index.html new file mode 100644 index 0000000000..907a08a8e2 --- /dev/null +++ b/files/pt-pt/web/api/file/name/index.html @@ -0,0 +1,74 @@ +--- +title: File.name +slug: Web/API/File/name +tags: + - API + - File API + - Files + - Propriadade + - Referencia +translation_of: Web/API/File/name +--- +<div>{{APIRef("File API")}}</div> + +<div>Devolve o nome do ficheiro representado por um objeto {{domxref("File")}}. Por razões de segurança, o caminho é excluído desta propriedade.</div> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox notranslate">var <var>name</var> = <var>file</var>.name;</pre> + +<h2 id="Valor">Valor</h2> + +<p>Uma string, que contem o nome do ficheiro sem o caminho, por exemplo "<code>O meu Resumo.rtf</code>".</p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush: html notranslate"><input type="file" multiple onchange="processSelectedFiles(this)"> +</pre> + +<pre class="brush: js notranslate">function processSelectedFiles(fileInput) { + var files = fileInput.files; + + for (var i = 0; i < files.length; i++) { + alert("Filename " + files[i].name); + } +}</pre> + +<p>Veja os resultados abaixo:</p> + +<p>{{ EmbedLiveSample('Exemplo', 300, 50) }}</p> + + + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Estado</th> + <th scope="col">Comentário</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('File API', '#file-attrs', 'name')}}</td> + <td>{{Spec2('File API')}}</td> + <td>Definição inicial.</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade">Compatibilidade</h2> + +<div> + + +<p>{{Compat("api.File.name")}}</p> +</div> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li><em><a href="/en-US/docs/Using_files_from_web_applications">Using files from web applications</a></em></li> +</ul> diff --git a/files/pt-pt/web/api/file/type/index.html b/files/pt-pt/web/api/file/type/index.html new file mode 100644 index 0000000000..2b448d3086 --- /dev/null +++ b/files/pt-pt/web/api/file/type/index.html @@ -0,0 +1,75 @@ +--- +title: File.type +slug: Web/API/File/type +tags: + - API + - Ficheiros + - File API + - Propriedade + - Referencia + - Tipo de Ficheiro +translation_of: Web/API/File/type +--- +<div>{{APIRef("File API")}}</div> + +<p>Retorna a média (<a href="/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME</a>) representado por um objeto {{domxref("File")}}.</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="brush: js notranslate">var name = <var>file</var>.type;</pre> + +<h2 id="Valor">Valor</h2> + +<p>Uma <em>string</em>, que contem o tipo de média (MIME) que indica o tipo do ficheiro, por exemplo "<code>image/png</code>" é devolvido para imagens PNG.</p> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush: html notranslate"><input type="file" multiple onchange="showType(this)"> +</pre> + +<pre class="brush: js notranslate">function showType(fileInput) { + var files = fileInput.files; + + for (var i = 0; i < files.length; i++) { + var name = files[i].name; + var type = files[i].type; + alert("Filename: " + name + " , Type: " + type); + } +}</pre> + +<div class="blockIndicator note"> +<p><br> + <strong>Nota:</strong> Baseado na atual implementação, navegadores não leem a <em>bytestream</em> dum ficheiro para determinar a sua média. É feito uma ilação baseada na extensão do ficheiro; uma imagem PNG com uma extensão ".txt" é atribuída o tipo "<code>text/plain</code>" e não "<code>image/png</code>". Além disso, <code>file.type</code> é geralmente fiável apenas para ficheiros comuns como imagens, documentos HTML, áudio e vídeo. Extensões de ficheiros pouco comuns devolveriam uma cadeia de caracteres vazia. A configuração do cliente (por exemplo, o Registo do Windows) pode resultar em valores inesperados mesmo para tipos comuns. <code>Os programadores são aconselhados a não confiar nesta propriedade como o único esquema de validação.</code></p> +</div> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Estado</th> + <th scope="col">Comentário</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('File API', '#dfn-type', 'type')}}</td> + <td>{{Spec2('File API')}}</td> + <td>Definição inicial</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade">Compatibilidade</h2> + + + +<p>{{Compat("api.File.type")}}</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/File/Using_files_from_web_applications">Usar ficheiros de aplicações web</a></li> + <li>Publicação de blogue (em inglês): <em><a href="https://textslashplain.com/2018/07/26/be-skeptical-of-client-reported-mime-content-types/">Be skeptical of client-reported MIME types</a></em></li> +</ul> diff --git a/files/pt-pt/web/api/file/webkitrelativepath/index.html b/files/pt-pt/web/api/file/webkitrelativepath/index.html new file mode 100644 index 0000000000..35f155c1c6 --- /dev/null +++ b/files/pt-pt/web/api/file/webkitrelativepath/index.html @@ -0,0 +1,80 @@ +--- +title: File.webkitRelativePath +slug: Web/API/File/webkitRelativePath +tags: + - Ficheiro +translation_of: Web/API/File/webkitRelativePath +--- +<p>{{APIRef("File API")}}</p> + +<p>O <strong><code>File.webkitRelativePath</code></strong> é uma propriedade só de leitura que contém um {{domxref("USVString")}} que especifica o caminho do ficheiro em relação ao diretório selecionado pelo utilizador num elemento {{HTMLElement("input")}} com o seu conjunto de atributos {{htmlattrxref("webkitdirectory", "input")}}.</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox notranslate"> <code><em>relativePath = File</em></code>.webkitRelativePath</pre> + +<h3 id="Valor">Valor</h3> + +<p>Um {{domxref("USVString")}} que contem o caminho do ficheiro relativo ao diretório dos antepassados que o utilizador selecionou.</p> + +<h2 id="Example" name="Example">Exemplo</h2> + +<p>Neste exemplo, é apresentado um seletor de diretórios que permite ao utilizador escolher um ou mais diretórios. Quando o evento {{event("change")}} ocorre, é gerada e apresentada uma lista de todos os ficheiros contidos dentro das hierarquias de diretórios selecionados.</p> + +<h3 id="Conteúdo_HTML">Conteúdo HTML</h3> + +<pre class="brush: html notranslate"><input type="file" id="seletorDeFicheiros" name="listaDeFicheiros" webkitdirectory multiple /> +<ul id="listagem"></ul></pre> + +<h3 id="Conteúdo_JavaScript">Conteúdo JavaScript</h3> + +<pre class="brush: js notranslate">document.getElementById("seletorDeFicheiros").addEventListener("change", function(event) { + let output = document.getElementById("listagem"); + let ficheiros = event.target.files; + + for (let i = 0; i < ficheiros.length; i++) { + let item = document.createElement("li"); + item.innerHTML = ficheiros[i].webkitRelativePath; + output.appendChild(item); + }; +}, false); +</pre> + +<h3 id="Resultado">Resultado</h3> + +<p>{{ EmbedLiveSample('Example') }}</p> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Estado</th> + <th scope="col">Comentário</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{ SpecName('File System API', '#dom-file-webkitrelativepath', 'webkitRelativePath') }}</td> + <td>{{ Spec2('File System API') }}</td> + <td>Definição inicial.</td> + </tr> + </tbody> +</table> + +<p>Esta IPA não tem especificação oficial do W3C ou do WHATWG.</p> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidade</h2> + + + +<p>{{Compat("api.File.webkitRelativePath")}}</p> + +<h2 id="Ver_também">Ver também</h2> + +<ul> + <li><a href="pt-PT/docs/Web/API/File_and_Directory_Entries_API">API de entradas de ficheiros e diretórios</a></li> + <li>{{domxref("HTMLInputElement.webkitEntries")}}</li> + <li>{{domxref("HTMLInputElement.webkitdirectory")}}</li> +</ul> |