Skip to content

Commit 74bf6cc

Browse files
authored
YeetYourFiles v.1.0 | Add YeetYourFiles (#364)
1 parent 0656164 commit 74bf6cc

File tree

6 files changed

+1746
-0
lines changed

6 files changed

+1746
-0
lines changed
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# YeetYourFiles Extension Documentation
2+
3+
*"Upload files to the cloud by throwing it into outer space!"*
4+
5+
The YeetYourFiles extension allows you to upload files directly from your PenguinMod/TurboWarp projects to the YeetYourFiles hosting service. This extension provides blocks for uploading various types of files, tracking upload status, and retrieving file information.
6+
7+
## File Upload Blocks
8+
9+
### Upload File Data
10+
```scratch
11+
upload file data [data] name [file.txt] :: #FF8C00
12+
```
13+
Uploads file data with a specified filename to YeetYourFiles.
14+
15+
Parameters:
16+
- **data**: The file content as a string, base64 encoded data, or data URL
17+
- **name**: The filename to use for the uploaded file
18+
19+
Examples:
20+
- Upload text: `upload file data [Hello World!] name [greeting.txt]`
21+
- Upload base64 image: `upload file data [iVBORw0KGgoAAAANSUhEUg...] name [image.png]`
22+
- Upload JSON data: `upload file data [{"name": "John", "age": 30}] name [data.json]`
23+
- It can also upload data urls
24+
25+
### Upload File from URL
26+
```scratch
27+
upload file from URL [https://example.com/image.png] :: #FF8C00
28+
```
29+
Downloads a file from a URL and uploads it to YeetYourFiles.
30+
31+
Parameters:
32+
- **URL**: The web address of the file to download and upload
33+
34+
Examples:
35+
- Upload remote image: `upload file from URL [https://picsum.photos/200/300]`
36+
- Upload remote document: `upload file from URL [https://example.com/document.pdf]`
37+
38+
### Open File Dialog
39+
```scratch
40+
open file dialog and upload :: #FF8C00
41+
```
42+
Opens a file picker dialog allowing users to select and upload files from their device.
43+
44+
This block:
45+
- Opens the native file selection dialog
46+
- Accepts any file type
47+
- Automatically uploads the selected file
48+
- Updates all file information blocks with the upload results
49+
50+
## File Information Blocks
51+
52+
### Last Uploaded File ID
53+
```scratch
54+
(last uploaded file ID :: #FF8C00)
55+
```
56+
Returns the unique identifier of the most recently uploaded file.
57+
58+
Examples:
59+
- File ID: `3af5f431-b4a2-414a-8524-f878551e7c59`
60+
- Can be used to reference the file in other operations
61+
62+
### Last Uploaded File URL
63+
```scratch
64+
(last uploaded file URL :: #FF8C00)
65+
```
66+
Returns the complete web address where the uploaded file can be accessed.
67+
68+
Examples:
69+
- Full URL: `https://yyf.mubilop.com/file/abc123def456`
70+
- Direct access link to view or download the file
71+
72+
### Last Uploaded File Short Hash
73+
```scratch
74+
(last uploaded file short hash :: #FF8C00)
75+
```
76+
Returns a the short hash used by the server on some routes.
77+
78+
Examples:
79+
- Short hash: `abc123cd`
80+
81+
### Last Uploaded File Data
82+
```scratch
83+
(last uploaded file data :: #FF8C00)
84+
```
85+
Returns the complete upload response as a JSON string containing the response from the server (should be used for advanced stuff)
86+
87+
Example response:
88+
```json
89+
{
90+
"message":"File uploaded successfully",
91+
"fileId":"16fd17d4-0d36-4318-9452-f19cb3259374",
92+
"fileUrl":"/file/123456ab/MubiIsCool.mov",
93+
"shortHash":"123456ab"
94+
}
95+
```
96+
97+
## Status and Monitoring Blocks
98+
99+
### Upload Status
100+
```scratch
101+
(upload status :: #FF8C00)
102+
```
103+
Returns the current status of file uploads.
104+
105+
Possible values:
106+
- `idle`: No upload in progress
107+
- `uploading`: File upload is currently in progress
108+
109+
### Upload Successful?
110+
```scratch
111+
<upload successful? :: #FF8C00>
112+
```
113+
Returns true if the last upload operation completed successfully, false otherwise.
114+
115+
Examples:
116+
- `true`: Last upload completed without errors
117+
- `false`: Last upload failed or encountered an error
118+
119+
### Uploaded?
120+
```scratch
121+
<uploaded? :: #FF8C00>
122+
```
123+
Returns true if any file has been uploaded during the current session, false otherwise.
124+
125+
Examples:
126+
- `true`: At least one file has been uploaded since the project started
127+
- `false`: No files have been uploaded yet
128+
129+
### Total Files on YeetYourFiles
130+
```scratch
131+
(total files on YeetYourFiles :: #FF8C00)
132+
```
133+
Returns the total number of files currently hosted on the YeetYourFiles service.
134+
135+
Examples:
136+
- `15234`: Total files across all users
137+
- Updates each time the block is used
138+
139+
## Usage Examples
140+
141+
### Basic Text Upload
142+
```scratch
143+
when flag clicked
144+
upload file data [Hello from Scratch!] name [message.txt]
145+
wait until <upload successful?>
146+
say (join [File uploaded: ] (last uploaded file URL)) for (2) seconds
147+
```
148+
149+
### Upload with Status Monitoring
150+
```scratch
151+
when flag clicked
152+
upload file data [{"score": 100, "level": 5}] name [game-data.json]
153+
repeat until <not (upload status) = [uploading]>
154+
say [Uploading...] for (0.1) seconds
155+
end
156+
if <upload successful?> then
157+
say [Upload complete!] for (2) seconds
158+
else
159+
say [Upload failed!] for (2) seconds
160+
end
161+
```
162+
163+
### Interactive File Upload
164+
```scratch
165+
when [space v] key pressed
166+
open file dialog and upload
167+
wait until <uploaded?>
168+
if <upload successful?> then
169+
set [file count v] to (total files on YeetYourFiles)
170+
say (join [Uploaded! Total files: ] (file count)) for (2) seconds
171+
end
172+
```
173+
174+
## Error Handling
175+
176+
(You can use PenguinMod's Try and Catch block with it!)
177+
178+
The extension includes built-in error handling for common issues:
179+
180+
- **No file data**: Returns error when trying to upload empty data
181+
- **Invalid URL**: Returns error for malformed or inaccessible URLs
182+
- **Network issues**: Handles connection failures gracefully
183+
- **Server errors**: Provides feedback for server-side upload issues
184+
185+
When an upload fails:
186+
- The `upload successful?` block returns false
187+
- The `upload status` returns to "idle"
188+
- Error information is stored in the upload data for debugging
189+
190+
## Service Information
191+
192+
**YeetYourFiles Service**: https://yyf.mubilop.com
193+
- Free file hosting service
194+
- No registration required
195+
- Supports files up to reasonable size limits
196+
- Files are publicly accessible via direct URLs
197+
198+
## Additional Notes
199+
200+
- The extension requires unsandboxed mode to function properly
201+
- File uploads are performed asynchronously
202+
- All uploaded files become publicly accessible via their URLs
203+
- The service maintains a global counter of total uploaded files
204+
- File metadata is preserved including original filenames and upload timestamps

src/lib/Documentation/pages.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import PagePenguinAI from "./PenguinAI.md?raw";
2222
// AuthPenguin
2323
import PageAuthPenguin from "./AuthPenguin.md?raw";
2424

25+
// YeetYourFiles
26+
import PageYeetYourFiles from "./YeetYourFiles.md?raw";
27+
2528
import PageMoreTypes from "./More-Types.md?raw";
2629

2730
// Boxed Physics
@@ -55,6 +58,9 @@ export default {
5558
// AuthPenguin
5659
"AuthPenguin": PageAuthPenguin,
5760

61+
// YeetYourFiles
62+
"YeetYourFiles": PageYeetYourFiles,
63+
5864
"more-types": PageMoreTypes,
5965

6066
// Boxed Physics

src/lib/extensions.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,16 @@ export default [
339339
unstable: true,
340340
unstableReason: "File System Access is not supported by all browsers.\nProjects can maliciously edit files that you open.",
341341
},
342+
{
343+
name: "YeetYourFiles",
344+
description: "Upload files to the cloud by throwing it to outer space!",
345+
code: "MubiLop/yeetyourfiles.js",
346+
banner: "MubiLop/yeetyourfiles.png",
347+
creator: "cicerorph",
348+
creatorAlias: "MubiLop",
349+
documentation: "YeetYourFiles",
350+
isGitHub: true,
351+
},
342352
{
343353
name: "File Upload",
344354
description: "Upload files to the Network, can also used with Files extension.",

0 commit comments

Comments
 (0)