Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

[WIP] UploadR - V2 #19

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.css linguist-vendored

###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0
EXPOSE 80
EXPOSE 443

COPY . /app
WORKDIR /app

RUN dotnet restore
RUN dotnet build
RUN dotnet publish -c Release -o /app/publish

ENV UPLOADR_PATH=./publish/uploadr.json

ENTRYPOINT ["dotnet", "./publish/UploadR.dll", "/Database:Hostname=uploadr-postgres"]
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2017-2020+ Allan Mercou
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
13 changes: 13 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2021 Allan Mercou

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
64 changes: 5 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,13 @@

[![Build Status](https://dev.azure.com/allanmercou/uploadr/_apis/build/status/Kiritsu.uploadr?branchName=master)](https://dev.azure.com/allanmercou/uploadr/_build/latest?definitionId=7&branchName=master)

UploadR is a simple server-side uploading service made with ASP.NET Core 3.1.

# Routes

## Anonymous requests
> `POST /api/account` - Creates a new unverified account. Requires `AccountCreateModel` form.

> `GET /api/upload/{string|guid:filename}{string:password}` - Gets an upload by its name or guid. Password can be specified if the file requires a password.

> `GET /api/shorten/{string:shortenedName}{string:password}` - Redirects to the target of this shortened url.

## Authenticated requests (Unverified)
> `POST /api/account/verify` - Verifies an unverified account.

## Authenticated requests (User)
> `DELETE /api/account{bool:cascade}` - Deletes the current account.

> `PATCH /api/account/reset` - Resets the current user's token.

> `POST /api/upload/` - Creates an upload. Requires `UploadModel` form.

> `DELETE /api/upload/{string|guid:filename}` - Removes an upload by its name or guid.

> `DELETE /api/upload/` - Removes multiple uploads by their ids.

> `GET /api/upload/{string|guid:filename}/details` - Gets an upload's details by its id or guid.

> `GET /api/upload/uploads` - Gets details of every upload created by the current authenticated user.

> `POST /api/shorten/` - Creates a shortened url. Requires `ShortenModel` form.

> `DELETE /api/shorten/{string|guid:shortenedId}` - Removes a shortened url by its name or guid.

> `GET /api/shorten/{string|guid:shortenedId}/details` - Gets a shortened url's details by its name or guid.

> `GET /api/shorten/shortens` - Gets details of every shortened url created by the current authenticated user.


## Authenticated requests (Admin)
> `PATCH /api/account/{userId}/block` - Blocks a user by its id.

> `PATCH /api/account/{userId}/unblock` - Unblocks a user by its id.

> `PATCH /api/account/{userId}/reset` - Resets a user's token.

> `DELETE /api/upload/{string|guid:filename}` - Removes an upload by its name or guid.

> `GET /api/upload/{guid:userguid}/uploads` - Gets details of every upload created by the given user guid.

> `DELETE /api/shorten/{string|guid:shortenedId}` - Removes a shortened url by its name or guid.

> `GET /api/shorten/{guid:userguid}/shortens` - Gets details of every shortened urls created by the given user guid.


UploadR is a simple server-side uploading service made with ASP.NET Core 5.

# Requirements

In order to use UploadR, you need the following components:
- ASP.NET Core 3.1
- ASP.NET Core 5
- PostgreSQL Server
- Angular 8

# Configuration

Expand Down Expand Up @@ -92,9 +38,9 @@ CREATE DATABASE uploadr WITH OWNER 'uploadr';

# Using UploadR

You need `Visual Studio 2019` or the `.NET Core 3.1 SDK` in order to build UploadR.
You need `Visual Studio 2019` or the `.NET 5 SDK` in order to build UploadR.
If you are building from a terminal, use the following command:
```
dotnet publish -c Release -f netcoreapp3.1 -r [RUNTIME]
dotnet publish -c Release -r [RUNTIME]
```
You can replace [RUNTIME] by either `win-x64` or `linux-x64` depending on the target operating system. See Microsoft documentation for .NET Core runtime if you have troubles.
You can replace [RUNTIME] by either `win-x64`, `linux-x64`, etc. depending on the target operating system. See Microsoft documentation for .NET Core runtime if you have troubles.
12 changes: 6 additions & 6 deletions UploadR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ VisualStudioVersion = 16.0.29025.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UploadR.Database", "src\UploadR.Database\UploadR.Database.csproj", "{336CA9EF-C7E6-4D5C-97DD-00F6F670AF90}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UploadR", "src\UploadR\UploadR.csproj", "{836609FD-69AD-4DAC-BD6A-A7D0047FF155}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UploadR.Test", "src\UploadR.Test\UploadR.Test.csproj", "{C0DE99EC-A3EB-4176-B3B3-C71EBEC61542}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UploadR", "src\UploadR\UploadR.csproj", "{2253A588-2C5E-4792-BA6B-59D15D31B4B0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -19,14 +19,14 @@ Global
{336CA9EF-C7E6-4D5C-97DD-00F6F670AF90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{336CA9EF-C7E6-4D5C-97DD-00F6F670AF90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{336CA9EF-C7E6-4D5C-97DD-00F6F670AF90}.Release|Any CPU.Build.0 = Release|Any CPU
{836609FD-69AD-4DAC-BD6A-A7D0047FF155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{836609FD-69AD-4DAC-BD6A-A7D0047FF155}.Debug|Any CPU.Build.0 = Debug|Any CPU
{836609FD-69AD-4DAC-BD6A-A7D0047FF155}.Release|Any CPU.ActiveCfg = Release|Any CPU
{836609FD-69AD-4DAC-BD6A-A7D0047FF155}.Release|Any CPU.Build.0 = Release|Any CPU
{C0DE99EC-A3EB-4176-B3B3-C71EBEC61542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0DE99EC-A3EB-4176-B3B3-C71EBEC61542}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0DE99EC-A3EB-4176-B3B3-C71EBEC61542}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0DE99EC-A3EB-4176-B3B3-C71EBEC61542}.Release|Any CPU.Build.0 = Release|Any CPU
{2253A588-2C5E-4792-BA6B-59D15D31B4B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2253A588-2C5E-4792-BA6B-59D15D31B4B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2253A588-2C5E-4792-BA6B-59D15D31B4B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2253A588-2C5E-4792-BA6B-59D15D31B4B0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
30 changes: 18 additions & 12 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trigger:
- master

pool:
vmImage: 'ubuntu-16.04'
vmImage: 'windows-latest'

variables:
solution: '**/*.sln'
Expand All @@ -16,22 +16,28 @@ variables:
steps:
- task: UseDotNet@2
inputs:
version: 3.1.x
version: 5.0.x
displayName: 'Install .NET 5'

- script: dotnet restore

- script: dotnet publish --configuration $(buildConfiguration) --runtime linux-x64 --output $(Build.ArtifactStagingDirectory) --verbosity n
condition: succeeded()
displayName: 'Restore Solution'

- script: dotnet test
condition: succeeded()
displayName: 'Test Solution'

- script: dotnet build
condition: succeeded()
displayName: 'Pre-build'

- script: dotnet publish --configuration $(buildConfiguration) --runtime linux-x64 --output $(Build.ArtifactStagingDirectory) --verbosity n
condition: succeeded()
displayName: 'Publish Solution'

- task: PublishBuildArtifacts@1
condition: succeeded()
displayName: 'Publish Build Artifact'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: uploadr

- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'uploadr'
downloadPath: '$(System.ArtifactsDirectory)'
artifactName: uploadr
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
uploadr-postgres:
image: postgres
container_name: uploadr-postgres
environment:
- POSTGRES_DB=uploadr
- POSTGRES_USER=uploadr
- POSTGRES_PASSWORD=1234
volumes:
- database-data:/var/lib/postgresql/data

uploadr-app:
build: .
container_name: uploadr-app
depends_on:
- uploadr-postgres

volumes:
database-data:
Loading