Ich versuche, Dateien in Blob Azure aus einem MVC-App zu laden, ich folge this Tutorial, und ich bin in diesem Snippet stecken:Datei hochladen in Blob Azure
using (var fileStream = System.IO.File.OpenRead(@"path\myfile"))
{
blockBlob.UploadFromStream(fileStream);
}
Wie @"path\myfile"
machen dynamische ?? Wie kann ich den tatsächlichen Pfad meiner Datei abrufen, um sie dort einzufügen? Ich nehme auch anderen Vorschlag blob hochladen :)
UPDATE
Wie schlug ich den Code in meiner Ansicht hinzugefügt:
@model RiPSShared.Models.RiPSModels.AgencyNote
<h2>PostFile</h2>
<form action="@Url.Action("PostFile", "AgencyNotes", new { NoteId=Model.aut_id})" method = "post" enctype="multipart/form-data">
<label for="file1"> File name:</label>
<input type="file" name="file" id="file1" />
<input type="submit" value="Submit" />
</form>
und die vollen Action Controller:
public ActionResult PostFile(HttpPostedFileBase file, int NoteId)
{
CloudBlockBlob blockBlob = container.GetBlockBlobReference(path);
using (Stream fileStream = file.InputStream)
{
blockBlob.UploadFromStream(fileStream);
}
return RedirectToAction("Index");
}
nur darauf warten, 1 Minute erhalten es als Antwort zu wählen funktioniert super !!! – AlexGH
Ich schlage vor, dass Sie die relevanten Informationen (es gibt Formularpost aus Ihrer Sicht und Ihre Aktionsmethode param ist HttpPostedFileBase-Typ) in die Frage einbeziehen, um zukünftigen Lesern zu helfen. Ich wusste es, weil ich deine vorherige Frage gelesen habe. – Shyju
danke! Es ist jetzt aktualisiert :) – AlexGH